I've searched across SO, but couldn't able to find anything relevant my requirement.
Basically, I would like to restrict a textinput
field from getting any input starting/prefixed with 0 (although 0 can be suffixed).
I knew that we can use the restrict
property to do the restriction, and I'm finding it difficult to get a mxml relevant regular expression to handle this.
Any help?
Can you get the text field and do a conditional where if the charCode(0) is zero? Pure AS would look something like this.
var tf:TextField = new TextField();
public function Main()
{
tf.addEventListener(KeyboardEvent.KEY_DOWN, onkeydown);
addChild(tf);
}
private function onkeydown(e:Event):void
{
if (tf.text.charAt(0) == "0")
{
//Create an alert, snip the text field, cause a stackovereflow.
//Maybe hack the computer for bitcoins just because.
}
}