Hello
I'm trying to validate a flash form. In one case I need to know how to check if the value is a number.
If someone could show me this if-sentence, i would be very grateful! :)
Hello
I'm trying to validate a flash form. In one case I need to know how to check if the value is a number.
If someone could show me this if-sentence, i would be very grateful! :)
Use Number to cast a String to a Number and then isNaN to check if the result is a Number:
var str:String="1234";
var n:Number = Number(str);
if (isNaN(n)) {
trace(str+" is not a number");
} else {
trace(str+" is a number");
}
str="12a4";
n=Number(str);
if (isNaN(n)) {
trace(str+" is not a number");
} else {
trace(str+" is a number");
}