AVOID CHARACTERS IN A TEXTFIELD
How can i avoid that a user types some character(for example '<') in a textfield?
You can use a regular expression on a TextField using setRegex.
Well. Many ways:
1 - You can listen for entered keys, and if < is entered, you remove it, or display some message...
2 - you can add a validator via setValidator (but that will only be checked when leaving the field, not when typing)
3 - As suggested, you can set a regex expression via setRegex(but that will also be only checked when leaving the field, not when typing)
How can i do it?
Originally Posted by micgala
Add a listener to the field using addListener(...) and implement the handleEvent method to do what you want.
Specify what event you want to listen for, I suppose you need something like Events.KeyPress or one of the other Key... - events.
I fixed it by using Textfield.maskRe = /your regular expression/
This will avoid user to type anything which does not comprehend your regex.
remember on put your regEx into forward slashes!!
hope this help you guys.