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

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

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

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.

… what about isNaN() ?

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]

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

YOU ARE ALWAYS RIGHT. :stuck_out_tongue:
[AS]kax._hero = senocular;[/AS]

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 ;))

thanks guy I will give it a go.

Good luck! =)

Hope you can sort it out!! :stuck_out_tongue: