A useful attribute restrict (constraint, restriction) of textinput In Flex is found. Let's take a look at the example below:
1, <mx: textinput id = "test_ti" width = "160" maxchars = "20" restrict = "0-9" text = "0"/>
In this way, the input box can only contain up to 20 characters and can only contain numbers ranging from 0 to 9.
2, <mx: textinput id = "test_ti" width = "160" maxchars = "20" restrict = "0-9/." text = "0"/>
In this way, you can enter numbers between 0 and 9 in the input box, and enter '.', which must be separated '/'.
3, <mx: textinput id = "test_ti" width = "160" restrict = "0-9/AB" text = "0"/>, in the input box, enter a number between 0 and 9, and a, or B.
4, <mx: textinput id = "test_ti" width = "160" restrict = "a-z" text = "0"/>
You can enter any English letter between A and Z. '-' indicates the interval. To enter '-', you must add '/', such /-
Conclusion:
The advantage of using restrict is that it saves the trouble of verification. For example, if restrict = "0-9" is added to check whether it is a number, you do not need to check it, this is because the input box can only enter numbers between 0 and 9.
Original document address: http://chuan315.javaeye.com/blog/233243