Alex Rivera | Logout

Simplest way to check if a string converted to a number is actually a number in actionscript

Asked 2009-08-06T17:42:04.190
15

Not sure if this makes sense, but I need to check if a server value returned is actually a number. Right now I get ALL number values returned as strings ie '7' instead of 7.

What's the simplest way to check if string values can actually be converted to numbers?

Edit
Report

1 Answer

0

Put this into any function where you want only numbers to stay
joy_edit1 is a TextInput Object (spark)

//is a number check
if( isNaN(Number(joy_edit1.text)) ) {
  joy_edit1.text = "";
  return void;
}
answered 2011-10-28T04:52:36.987

Your Answer