Prevent Specific Characters From Entering Textfield.
Hello,
There is an attribute .restrict but as the defined it only prevents other characters from entering the textfield, restricting the textfield to the given characters.
I want to prevent characters 1-10 from entering the textfield.
The code below does not work the right way.
txt.border = true; //
function down(event:KeyboardEvent):void
{
/*
for (var i:uint=48; i<58; i++)
{
if (event.keyCode == i)
{
txt.text = txt.text.replace(/.$/,"");
}
}
*/
//No ASCII, No RegExp
for (var i:uint=0; i<10; i++)
{
if (txt.text.indexOf(String(i)))
{
txt.text = txt.text.replace(String(i),"");
}
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, down);
There must be surely be a built in method.