# \*\* Is there a !true test for numbers ? \*\*

**URL:** <https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930>\
**Category:** flash\
**Created:** [August 20, 2003, 8:26am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930 "2003-08-20T08:26:46Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Vulcan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/the_vulcan/32/145_2.png) [@The\_Vulcan](https://forum.kirupa.com/u/The_Vulcan)\
**Post date:** [August 20, 2003, 8:26am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/1 "2003-08-20T08:26:46Z")

</div>

There is a crapy little file attached if needed…

If you have a number of boxes that you want the user to enter numbers into, that are then added up…

if they put a non number in you get “NaN” displayed

does that mean you have to do a if() test on every entry to ensure that a number has been entered, and if one hasn’t its to be replaced with 0 ?

if that is the case what is the if (clause ); please

Also in relation to this, if a user inputs a number into a input text field, is it possible that this is imediatley updated into a dynamic text field… or do you HAVE to asign a button to do this ?

Thanks in advance guys/ and girls

---

<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:** [August 20, 2003, 9:01am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/2 "2003-08-20T09:01:27Z")

</div>

I don’t have Flash installed in this PC, but this thread might help: [http://www.kirupaforum.com/forums/showthread.php?s=&threadid=31224](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=31224).

---

<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:** [August 20, 2003, 9:57am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/3 "2003-08-20T09:57:59Z")

</div>

Thanks for your response Kax

I looked at you code and tried to create the addition function but I as yet can not get it to function. Below is the code.  
[AS]  
sushi\_plater\_order = 0; //input text field  
chop\_stick\_order = 0; //input text field  
wasabi\_order = 0; //input text field

sushi\_plater\_total = 0; //dynamic text field  
chop\_stick\_total = 0; //dynamic text field  
wasabi\_total = 0; //dynamic text field  
\_total = 0; //dynamic text field

sushi\_plater\_order.onChanged = addition;  
chop\_stick\_order.onChanged = addition;  
wasabi\_order.onChanged = addition;

addition = function () {  
sushi\_plater\_total = sushi\_plater\_order \*10;  
chop\_stick\_total = chop\_stick\_order \*10;  
wasabi\_total = wasabi\_order \*10;  
\_total =(sushi\_plater\_total + chop\_stick\_total + wasabi\_total);  
};  
[/AS]

Also for checking that it is a number, I may not have used this correctly.  
[AS].restrict = “0-9.”;[/AS]

At the moment I am using  
Property; the IEEE-754 value representing Not A Number (NaN).

[AS]if(sushi\_plater\_order = IEEE-754 ){  
sushi\_plater\_order = 0;}[/AS]

This half works, that is if a letter or nothing is entered it sets the value to 0 so that you dont get NaN. However even when putting a number in there it still sets it to 0.

---

<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:** [August 20, 2003, 10:37am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/4 "2003-08-20T10:37:10Z")

</div>

… what about isNaN() ?

---

<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:** [August 20, 2003, 10:37am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/5 "2003-08-20T10:37:54Z")

</div>

From what I can tell, you’re using variables and not the instance names.

The onChanged handler is a TextField event, and restrict is a TextField property. You’ll need to assign instance names to your TextFields, and update the code to use the instance names and not the variables.

Also, you could use the isNaN function:  
[AS]if (isNaN(sushi\_plater\_order)) sushi\_plater\_order = 0;[/AS]  
[EDIT]lol @ senocular :P[/EDIT]

---

<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:** [August 20, 2003, 10:50am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/6 "2003-08-20T10:50:18Z")

</div>

Oooooo, kax said it too so it must mean Im right =)

---

<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:** [August 20, 2003, 10:51am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/7 "2003-08-20T10:51:49Z")

</div>

YOU ARE **ALWAYS** RIGHT. 😛  
[AS]kax.\_hero = senocular;[/AS]

---

<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:** [August 20, 2003, 10:53am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/8 "2003-08-20T10:53:59Z")

</div>

Ive only been really lucky so far (I do it by reading your mind and posting your thoughts first making it seem as if they were mine and taking all the credit for it ;))

---

<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:** [August 20, 2003, 11:37am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/9 "2003-08-20T11:37:38Z")

</div>

thanks guy I will give it a go.

---

<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:** [August 20, 2003, 11:59am UTC](https://forum.kirupa.com/t/is-there-a-true-test-for-numbers/28930/10 "2003-08-20T11:59:49Z")

</div>

Good luck! =)

Hope you can sort it out!! 😛
