Page 1 of 1

Javascript Question HELP HELp

Posted: Wed Jun 16, 2004 7:59 am
by stantheman
I'm trinyingg to check to make sure the there are no letters entered into the field just numbers. But this is stuck in the if stament and never leaves

Code: Select all

if(phonecheck.value = "NaN")
{
alert("Must Be A number no letters");
return(false);
}
else
{
return(true);
}

Posted: Wed Jun 16, 2004 8:17 am
by pelegk2
nope that wrong beacuse value isnt in the meaning of number but as the content of the text box!!!!
u need to use regexp to checkout if the typed is ligeal!

Posted: Wed Jun 16, 2004 12:16 pm
by feyd
uhm.. that code would set phonecheck.value to the string 'NaN'..

nope that wrong beacuse value isnt in the meaning of number but as the content of the text box!!!!
u need to use regexp to checkout if the typed is ligeal!
... or just parseInt() it.