AlishaMarie
05-05-2003, 04:08 PM
Is there a function that's the opposite of isNAN?? I have a value on a field that I need to verify. It's a name field so I don't want to allow any numbers.
Please help! ;-)
Please help! ;-)
|
Click to See Complete Forum and Search --> : opposite of isNAN?? AlishaMarie 05-05-2003, 04:08 PM Is there a function that's the opposite of isNAN?? I have a value on a field that I need to verify. It's a name field so I don't want to allow any numbers. Please help! ;-) Charles 05-05-2003, 05:05 PM <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="Content-Script-Type" content="text/javascript"> <form action=""> <div> <label>Name:<br> <input type="text" onchange="if (!/^[a-z\s]+$/i.test(this.value)) {alert('That would not appear to be a valid name.'); this.value = ''; this.focus()}"> </label><br> <input type="submit"> <div> </form> SniperX 05-06-2003, 12:26 AM You could just use this... if (isNAN(string) == false) { return true; } else{ return false; } i.e. If isNAN shows that there are letters, proceed, or if there are numbers then stop the user. Charles 05-06-2003, 04:31 AM Originally posted by SniperX You could just use this... if (isNAN(string) == false) { return true; } else{ return false; } i.e. If isNAN shows that there are letters, proceed, or if there are numbers then stop the user. Which is the same as return !Boolean(Number(string)) but neither will work the way AlishaMarie wants, returning true when numbers and letters are mixed. SniperX 05-06-2003, 04:42 AM She said she doesnt want numbers in the input... Charles 05-06-2003, 04:47 AM And your method will not catch "Charles 2". webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |