IndyB
08-05-2003, 10:10 AM
I have this form field:
<input type="text" name="units" value="1" OnBlur="check_units()">
I need to us isNaN to make sure the users enter only numbers in this field.
To do that, I'm using this javascript:
function check_units()
{
var u = document.frmLookup.units.value;
if(isNaN(u) == true)
{ alert("That is not a valid number."); }
}
It works if I put a non number in the field then click out of the field. But then when I go back to put a number in the field and click out again, it still displays the alert, even though I've entered a number in the field. Can anyone see what I'm doing wrong here?
<input type="text" name="units" value="1" OnBlur="check_units()">
I need to us isNaN to make sure the users enter only numbers in this field.
To do that, I'm using this javascript:
function check_units()
{
var u = document.frmLookup.units.value;
if(isNaN(u) == true)
{ alert("That is not a valid number."); }
}
It works if I put a non number in the field then click out of the field. But then when I go back to put a number in the field and click out again, it still displays the alert, even though I've entered a number in the field. Can anyone see what I'm doing wrong here?