Published in: ActionScript
/** * Checks if an email is written correctly * * @param email The email we're checking * @return A result boolean */ function validateEmail(email:String):Boolean { //check for @ if (email.indexOf("@")>0) { // strip blank spaces at end if (email.indexOf(" ")>0) { email = email.substr(0, email.indexOf(" ")); } if (email.indexOf(" ")>0) { // Has blank spaces in the middle. return false; } else { // check for the dot var ext = email.substr(email.lastIndexOf(".")+1, email.length); if (ext.length>1 && ext.length<4) { // Passed return true; } else { // No dot found return false; } } } else { // No @ found return false; } }
You need to login to post a comment.
