In this tutorial we will learn how to creating RegExp Validation
this is the code.
var bool:Boolean;
var str:String = "";
function checkEmail(s:String):Boolean
{
//This tests for correct email address
var p:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var r:Object = p.exec(s);
if (r == null)
{
return false;
}
return true;
}
function onClick(event:Event):void
{
str=input_txt.text;
if (str.length > 1)
{
bool = (checkEmail(str));
if (bool)
{
output_txt.text = "Thank You !";
} else
{
output_txt.text = "Invalid E-mail";
}
} else
{
output_txt.text = "Please Enter your E-mail !";
}
str="";
}
check_mc.addEventListener(MouseEvent.CLICK, onClick);
Preview
Download .zip
No comments:
Post a Comment