//check for spaces
if (inputEmail.indexOf(" ")>0) {
return false;
}
//bust the email apart into what comes before the @ and what comes after
var emailArray:Array = inputEmail.split("@");
//make sure there's exactly one @ symbol
//also make sure there's at least one character before and after the @
if (emailArray.length != 2 || emailArray[0].length == 0 || emailArray[1].length == 0) {
return false;
}
//bust apart the stuff after the @ apart on any . characters
var postArray:Array = emailArray[1].split(".");
//make sure there's at least one . after the @
if (postArray.length<2) {
return false;
}
//make sure there's at least 1 character in in each segment before, between and after each .
for (var i:Number = 0; i
return false;
}
}
//get what is left after the last .
var suffix = postArray[postArray.length-1];
//make sure that the segment at the end is either 2 or 3 characters
if (suffix.length<2 || suffix.length>3) {
return false;
}
//it passed all tests, it's a valid email
return true;
}
//To Use it
if (checkEmail(txtEPost8.text)) {
trace("EMAIL VALID");
} else {
trace("EMAIL NOT VALID");
}

No comments:
Post a Comment