zobernjik
04-26-2004, 07:23 AM
Hello guys,
How can I validate that users have entered text or anything else for that matter and give them a pop up message informing they can only enter numbers.
I am new to this as you can see by my question,I hope somebody can help.
Regards
Philip M
04-26-2004, 07:46 AM
Here is an example:-
<tr>
<td><font face="Arial"><em><b>Club Membership No. (if applicable)</b></em></font></td>
<td><input type="text" size="8" maxlength="8" name="MemNumber" onblur="if(/\D/g.test(this.value)){alert('Only current Club membership numbers are valid in this box. ');this.value='';this.focus()}; </font></td></tr>
Kylena
04-26-2004, 08:02 AM
Here's a script that works the same as Philip's.
var f = document.forms[0]
var v = f.NumField.value
for (i=0; i<v.length; i++)
{
if ((v.charCodeAt(i)<48 || v.charCodeAt(i)>57) && v.charCodeAt(i) !== 44 )
{
alert ( "This must be numeric." )
f.NumField.value = "";
f.NumField.focus()
return false
}
}
Garadon
04-26-2004, 10:33 AM
if(parseFloat(Field.value,10)==Field.value){}
or
if(parseInt(Field.value,10)==Field.value){}
liorean
04-26-2004, 10:40 AM
parseFloat doesn't need that second argument of 10 since it may only take decimal numbers, but the parseInt needs it.
glenngv
04-26-2004, 10:43 AM
parseFloat() has no radix parameter unlike parseInt(). It always parse numbers in base 10
liorean
04-26-2004, 10:43 AM
parseFloat() has no radix parameter unlike parseInt(). It always parse numbers in base 10
Beat you to it :);):)