A simple check for a valid email address, makes sure it has an ‘@’ and a ‘.’
public function checkEmail(_email:String):Boolean {
var passCheck:Boolean = false
var atLoc:int = _email.indexOf(“@”)
var dotLoc:int = _email.indexOf(“.”)
if (atLoc > 0 && dotLoc >0) {
passCheck =true
}
return passCheck
}
Well thanks to Jon, I’ve now looked into a method using Regular Expressions which seems to be a whole bunch better. Sadly the Adobe help was crappy and I instead found some working source here
function isValidEmail(email:String):Boolean {
var EMAIL_REGEX : RegExp = /^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/i;
return Boolean(email.match(EMAIL_REGEX)));
}