# Detecting var output "NaN"

**URL:** <https://forum.kirupa.com/t/detecting-var-output-nan/56862>\
**Category:** Uncategorized\
**Created:** [July 8, 2004, 7:21am UTC](https://forum.kirupa.com/t/detecting-var-output-nan/56862 "2004-07-08T07:21:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![swammerdami](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@swammerdami](https://forum.kirupa.com/u/swammerdami)\
**Post date:** [July 8, 2004, 7:21am UTC](https://forum.kirupa.com/t/detecting-var-output-nan/56862/1 "2004-07-08T07:21:45Z")

</div>

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.

```auto
 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.

```auto
 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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 8, 2004, 7:35am UTC](https://forum.kirupa.com/t/detecting-var-output-nan/56862/2 "2004-07-08T07:35:55Z")

</div>

Use the isNaN function 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 8, 2004, 8:20am UTC](https://forum.kirupa.com/t/detecting-var-output-nan/56862/3 "2004-07-08T08:20:15Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 8, 2004, 10:03am UTC](https://forum.kirupa.com/t/detecting-var-output-nan/56862/4 "2004-07-08T10:03:54Z")

</div>

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.
