For AS 2.0 you can use the following validation assuming that the email is in the TextField named email:
var myEmail:String = email.text;
if ( (myEmail != "")
&& ((myEmail.indexOf("@", 0) < 0)
|| (myEmail.indexOf(".", 0) < 0)
|| (myEmail.lastIndexOf("@") < 1
|| myEmail.lastIndexOf(".") - myEmail.lastIndexOf("@") < 2
|| myEmail.length - myEmail.lastIndexOf(".") < 3)) )
{
// the address isn't valid
} else {
// the address is valid
}
For AS 3.0 you can use the following validation assuming that the email is in the TextField named email:
var emailValidator:RegExp = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/gi;
if( !emailValidator.test(email.text) )
{
// the address isn't valid
} else {
// the address is valid
}