I have a problem. I'm new at AS3 and i need alot of help.
I have a scenario here. I have 2 fields which i require the users to key in. 1) Name 2) Telephone No.
How do I do a check if the characters keyed in are at least 5 characters long and must only consist of A-Z and a-z for the Username field.
And as for the telephone no, the field to only have 8 digits and no other characters such as letters and symbols.
And all error msgs are displayed in another ladel next to each text field.
I have created the fields but i'm not sure on how to go about doing the validation checks.
- Code: Select all
//text field for Name
var myFormat1:TextFormat = new TextFormat();
var myFormat1a:TextFormat= new TextFormat();
var myFormat1error:TextFormat= new TextFormat();
myFormat1.size=15;
myFormat1a.size=15;
myFormat1error.size=15;
myFormat1.align=TextFormatAlign.CENTER;
myFormat1a.align=TextFormatAlign.CENTER;
myFormat1error.align=TextFormatAlign.CENTER;
var myText1a:TextField = new TextField();
myText1a.defaultTextFormat=myFormat1a;
myText1a.text="Name:";
addChild(myText1a);
var myText1:TextField = new TextField();
myText1.defaultTextFormat=myFormat1;
myText1.text="Type your name here";
addChild(myText1);
var myText1error:TextField = new TextField();
myText1error.defaultTextFormat=myFormat1a;
myText1error.text="Error appears here";
addChild(myText1error);
myText1.border=true;
myText1.wordWrap=true;
myText1.width=150;
myText1.height=20;
myText1.x=150;
myText1.y=100;
myText1.type="input";
myText1a.width=150;
myText1a.height=20;
myText1a.x=50;
myText1a.y=100;
myText1error.width=150;
myText1error.height=20;
myText1error.x=290;
myText1error.y=100;
//telephone field for Name
var myFormat2:TextFormat = new TextFormat();
var myFormat2a:TextFormat= new TextFormat();
var myFormat2error:TextFormat= new TextFormat();
myFormat2.size=15;
myFormat2a.size=15;
myFormat2error.size=15;
myFormat2.align=TextFormatAlign.CENTER;
myFormat2a.align=TextFormatAlign.CENTER;
myFormat2error.align=TextFormatAlign.CENTER;
var myText2a:TextField = new TextField();
myText2a.defaultTextFormat=myFormat2a;
myText2a.text="Telephone No:";
addChild(myText2a);
var myText2:TextField = new TextField();
myText2.defaultTextFormat=myFormat2;
myText2.text="Type your Telephone No here";
addChild(myText2);
var myText2error:TextField = new TextField();
myText2error.defaultTextFormat=myFormat2;
myText2error.text="Error appears here";
addChild(myText2error);
myText2.border=true;
myText2.wordWrap=true;
myText2.width=150;
myText2.height=20;
myText2.x=200;
myText2.y=150;
myText2.type="input";
myText2a.width=300;
myText2a.height=40;
myText2a.x=1;
myText2a.y=150;
myText2error.width=300;
myText2error.height=40;
myText2error.x=270;
myText2error.y=150;
Could someone help me out please. Much Appreciated!
