Reputation: 449
I need to check if the text input contains anything that isnt int(number), wondering if it is possible.
if (!isNaN(s1.range))) {
s1.tet.text = "Please enter fields that only contains number";
Upvotes: 0
Views: 264
Reputation: 3151
If you need to check a text (String) to contain non digits, I would personally use RegExp. It would be easier for you to test the string against a regular expression.
Here's a simple example that will check for anything that is not a digit
var str:String = "04.sdf..";
var re:RegExp = /[\D]/g;
trace(str.match(re).length); // 6
In this example there are 6 char's that are not digits, therefor we can show an error to the user.
Here's a good tutorial on RegExp if you believe it can be helpful to you:
http://coursesweb.net/actionscript/regexp-regular-expressions-actionscript
Upvotes: 1