Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : Determining if a var is a number


tralfaz
3/4/2004 1:14:53 PM
[quoted text, click to view]

You can restrict the input to numbers only...
Example: input text box named agebox:
agebox.restrict = "0-9";

Here is restriction for alpha letters only...
agebox.restrict = "a-z A-Z";

Here is restriction for letters and numbers only without punctuation etc..
agebox.restrict = "a-z A-Z 0-9";

If the number of chars input is 0, don't evaluate it.
hth
tralfaz

tralfaz
3/4/2004 2:03:58 PM
BTW.. If you prefer not to use actionscript, you can also restrict the input
text box to numerals only by selecting properties for the input text box:
Properties..
Character button...
Check mark ONLY..
Check mark Numerals (0-9)
tralfaz


[quoted text, click to view]

James Fee
3/4/2004 4:02:55 PM
Look up how to use isNaN().

Jim
[quoted text, click to view]

mitsubishi
3/4/2004 8:51:55 PM
This probably is a simple problem but I have been struggling with it for some
time. I am trying to determine if a user supplied variable is a number. The
user inputs a value (their age) in an input text box. This means the value is
of type 'String". Using various functions, such as typeof, parseInt and the
Number object I can get a return of NaN if the value is not a number. However I
simply cannot use the return in an if statement eg if (age == NaN) of if(age ==
'NaN') just simply does not evaluate.

Any suggestions?
AddThis Social Bookmark Button