I found fiddle to change input style if filled. But it's using ID. I want to use class name. I used document.getElementsByClassName(), but it's not working. Anyone can help? Thanks.
Here is the code
html
<input type="text" id="subEmail" onchange="checkFilled();"/>
Javascript
function checkFilled() {
var inputVal = document.getElementById("subEmail");
if (inputVal.value == "") {
inputVal.style.backgroundColor = "yellow";
}
else{
inputVal.style.backgroundColor = "";
}
}
checkFilled();
and here is the link to Fiddle