Javascript Question HELP HELp

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
stantheman
Forum Commoner
Posts: 38
Joined: Wed May 26, 2004 8:57 am

Javascript Question HELP HELp

Post 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);
}
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply