Detecting var output "NaN"

I need to be able to detect if the input a user types into an Input text field is not a number (NaN). I thought this would be a breeze, but I am having trouble. First I created a function that sets a new variable equal to the input value multiplied by 1.

 valuetest = value*1;

For testing purposes I placed a temp text box on the stage (var: valuetest). Sure enough, when the function is called and if value contains anything but numbers, valuetest becomes NaN. Then later on the timeline I check what valuetest is.

 if (valuetest == "NaN") {
 	gotoAndPlay("error"); }

Does not do what it supposed to. I tried doing this several ways, including putting all the code into the function, but I can not get it to “see” the NaN as a variable. I replaced the “NaN” in the if statement with a number and it works when I input that number… so I suspect that the code is correct and the problem has to be something to do with how Flash deals with a NaN output. ???
I really could use some help on this, if anyone is willing.
Thanks!

Use the isNaN function :slight_smile:

Thanks Ilyas le G®eek! I didn’t even know that existed! :rolleyes:
I tried a couple of attempts to utilize it within my code, but I guess I dont understand how to use it. Looking around for examples has brought me no luck either.
If you have a bit more time, could you give me an example on how it could be used? …for example: can it be used in an if statement?

Again, thanks for steering me in the right direction!

Ilyas le G®eek, just wanted to thank you again!
It looks as if I figured it out. I was making it more complicated than it needs to be.