TextInput component settings in Flex methods that restrict the input of certain characters _flex

Source: Internet
Author: User
Tags lowercase regular expression
1. Limit the input of a character, with symbols ^ keep up with the characters to be restricted, can be followed by more than one character

<!--the input--> of the "~" Limit character
<mx:textinput id= "xxx" restrict= "^~"/>

<!--limit character "ab" Input-->
<mx:textinput id= "xxx" restrict= "^ab"/>

2. Settings can only enter some characters, will allow the input of the characters listed, you can also use-combination to represent the range of characters

<!--can only enter ABC-->
<mx:textinput id= "xxx" restrict= "abc"/>

<!--can only enter lowercase letters-->
<mx:textinput id= "xxx" restrict= "A-Z"/>

<!--only lowercase letters, uppercase letters, and numeric--> can be entered
<mx:textinput id= "xxx" restrict= "a-za-z0-9"/>

3. Combined use

<!--can only enter numbers and point numbers "."-->
<mx:textinput id= "xxx" restrict= "0-9\."/>

<!--only allow the number and-+ numbers to be entered "."-->
<mx:textinput id= "xxx" restrict= "0-9\+\-"/>

<!--only lowercase letters other than AB are entered-->
<mx:textinput id= "xxx" restrict= "A-z^ab"/>

<!--only allowed to enter numbers, English, Chinese characters-->
<mx:textinput id= "xxx" restrict= "0-9\a-z\^{' [\u4e00-\u9fa5] '}"/>

II: FONT color= #108ac6 >flex TextInput Restrict (regular expression, constraint, qualification)

A useful attribute restrict (constraint, qualification) for TextInput in Flex, look at the following example:
1,<mx:textinput id= "Test_ti" width= "160" "maxchars=" restrict= "0-9" text= "0"/>
In this way, the input box can only enter 20 characters, can only enter the number between 0 to 9, if you enter the other is not entered into the
2,<mx:textinput id= "Test_ti" width= "160" maxchars= "restrict=" 0-9\. "text=" 0 "/>
In this way, the input box can enter a number between 0 and 9, and the input '. ', the middle must be separated by ' \ '
3,<mx:textinput id= "Test_ti" width= "160" restrict= "0-9\ab" text= "0"/>
In this way, the input box can enter numbers 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, '-' to denote an interval, and if you want to enter '-', you must add ' \ ', such as \-
Conclusion:
The advantage of using restrict is to save the trouble of verification, such as whether the test is a number, if the addition of restrict= "0-9", there is no need to test, because this input box can only enter between 0 to 9 of the number, the other lose

For detailed information, please see: http://blog.minidx.com/2008/05/16/851.html

Three: <mx:textinput id= "UserName" maxchars= "4" restrict= "a-za-z0-9"/>

Restrict usage:
Textfield.restrict = "Here is what can be entered";
Field.restrict = "^ Here for the prohibition of input content";
The Restrict property supports some styles similar to regular expressions:
Field.restrict = "A-za-z"; Only size letters allowed
Field.restrict = "A-za-z"; Only letters and spaces are allowed
Field.restrict = "0-9"; Allow only numbers
Field.restrict = "^ABCDEFG"; Except for lowercase letters ABCDEFG are not allowed, others are allowed
Field.restrict = "^a-z"; All lowercase letters are not allowed, but other content is allowed, including uppercase letters
Field.restrict = "0-9^5"; Only numbers are allowed, but 5 exceptions
Let the restrict character contain letters with special meanings (for example-and ^):
Field.restrict = "0-9\\-"; Allow numbers and dashes
Field.restrict = "0-9\\^"; Allow numbers and ^
Field.restrict = "0-9\\\\"; Allow numbers and backslashes
You can also use the Unicode escape sequence to specify what is allowed. For example:
Field.restrict = "^\";
Note: ActionScript is case-sensitive, and if the Restrict property is set to ABC, allowing the uppercase form of letters (A,B and C) to be entered in lowercase (a,b and C), and vice versa. The Restrict property affects only what the user can enter, A script can put any text in a text field.

Add:

You can also append a limit to the number of characters entered, set the Maxchars property
<s:textinput id= "Textinput_test" restrict= "0-9\-\+" maxchars= "4"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.