Odd behavior when restricting text input to alphanumeric
Let's say I want to have a text input that only accepts a-z, A-Z and 0-9. I can set this up in MXML as shown:
<mx:TextInput id="myText" restrict="a-zA-z0-9" />
I needed to bar users from entering special characters, but for some reason the characters '^', '[' and ']' were still being allowed. Odd, since the behavior of the 'restrict' setting should have caught this. I was pretty sure this has to do with the fact that '^' is used in 'restrict' to mean 'and none of the following', and the square brackets are used to character sets.
Sure enough. Here's the fix:
<mx:TextInput id="myText" restrict="a-zA-z0-9^\^\[\]" />
That setting says "allow a-z, A-Z and 0-9" the first caret ('^') says "and none of the following: ", after which the caret is entered (with an escape sequence), followed by square brackets.
