I'm new in html and javascript, coming from C#. Now I have created an input field, which must only accept numeric input. Like so:
<input name="numemp" type="text" id="numemp" value="<%=numberofemp%>" maxlength="10" onkeypress="return isNumberKey(event)" />
And I found this javascript:
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57))
{
return false;
}
else
{
return true;
}
}
This is not clear for me, I get it that the code checks the pressed key is numeric. And if it is numeric it returns true. But where does the code ignores the input? I only see a return false when this happend...