![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
Flash Player 6.0.79.
Flash MX 2004.
textInputInstance
.restrict
Property; indicates the set of characters that a user may enter into the text field. The default value is undefined. If the value of the restrict property is null or empty string (""
), a user can enter any character. If the value of the restrict
property is a string of characters, you can enter only characters in the string into the text field; the string is scanned from left to right. A range may be specified using the dash (-).
The restrict
property only restricts user interaction; a script may put any text into the text field. This property does not synchronize with the Embed Font Outlines check boxes in the Property inspector.
If the string begins with "^", all characters are initially accepted and succeeding characters in the string are excluded from the set of accepted characters. If the string does not begin with "^", no characters are initially accepted and succeeding characters in the string are included in the set of accepted characters.
The backslash character may be used to enter the characters "-", "^", and "\", as in the following:
\^ \- \\
When you enter the \
character in the Actions panel within ""
(double quotes), it has a special meaning for the Actions panel's double quotes interpreter. It signifies that the character following the \
should be treated as is. For example, the following code is used to enter a single quotation mark:
var leftQuote = "\"";
The Actions panel's .restrict interpreter also uses \
as an escape character. Therefore, you may think that the following should work:
myText.restrict = "0-9\-\^\\";
However, since this expression is contained within double quotes, the following value is sent to the .restrict interpreter: 0-9-^\
, and the .restrict interpreter doesn't understand this value.
Because you must enter this expression within double quotes, you must not only provide the expression for the .restrict interpreter, but you must also escape the Actions panel's built-in interpreter for double quotes. To send the value 0-9\-\^\\
to the .restrict interpreter, you must enter the following code:
myText.restrict = "0-9\\-\\^\\\\";
In the following example, the first line of code limits the text field to uppercase letters, numbers, and spaces. The second line of code allows all characters except lowercase letters.
my_txt.restrict = "A-Z 0-9"; my_txt.restrict = "^a-z";
The following code allows a user to enter the characters "0 1 2 3 4 5 6 7 8 9 - ^ \" in the instance myText
. You must use a double backslash to escape the characters "-, ^, and \". The first "\" escapes the " ", the second "\" tells the interpreter that the next character should not be treated as a special character, as in the following:
myText.restrict = "0-9\\-\\^\\\\";
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |