My HTML code is:
<input onKeyPress="validateA(this.value)" type="text" id="AAA" name="AAA" size="10" placeholder="A">
<span id="aspan" class="validate"> </span>
and my Javascript is:
function validateA(valueOfAAA) {
if (isNaN(valueOfAAA)) {
document.getElementById('aspan').innerHTML="Please enter a numerical value.";
}
else {
document.getElementById('aspan').innerHTML="";
}
}
To clarify, my question is:
Why is the innerHTML="Please enter a numerical value." not firing until two letters OR numbers are typed into my input box?
change
onKeyPress()toonKeyUp()because when keypress triggered, the actual value of input is not captured yet.