The following example shows how you can control which characters a user can type into a Flash ActionScript 3.0 TextInput control by setting the restrict property.
Full code after the jump.
// ActionScript 3.0 /* Requires: * - TextInput component in Flash library */ import fl.controls.TextInput; var textInput:TextInput = new TextInput(); textInput.restrict = "0-9."; textInput.move(10, 10); addChild(textInput);
{ 1 comment… read it below or add one }
hi, I`m doing a project for the uni and I need to restrict fields just for letters in these fields.
The code below show how I`m doing. This is not working. I`d like to know what is missing.
Thanks
if (checkBox.selected==true) {
chvalue_txt.text=newAmount.toFixed(2);
interestPayable = (newAmount + loanAmount)* loanTerm * rateA;
totalPayable = (newAmount + loanAmount + interestPayable);
mnthlyPayment = totalPayable/(loanTerm * 12);
firstName=(firstName_txt.text);
firstName_txt.restrict=”A-z”;
surName=(surName_txt.text);
surName_txt.restrict=”A-z”;
rate_txt.text=rate.toFixed(2);
interestPayable_txt.text=”£ “+interestPayable.toFixed(2);
totalPayable_txt.text=”£ “+totalPayable.toFixed(2);
mnthlyPayment_txt.text=”£ “+mnthlyPayment.toFixed(2);
} else if (checkBox.selected==false) {
chvalue_txt.text=”";
}
trace(checkbox);
}