Return to Snippet

Revision: 19915
at November 3, 2009 12:05 by Winkyboy


Initial Code
*/ syntax:
if (!isValidEmail("my_NON_email.com")) {
    trace("FAIL");
}
*/

private function isValidEmail(email:String):Boolean {
    var emailExpression:RegExp = /([a-z0-9._-]+?)@([a-z0-9.-]+)\.([a-z]{2,4})/;
    return emailExpression.test(email);
}

Initial URL
http://www.lukegill.com/blog/as3-email-validation/

Initial Description
The source below is the function from the website with the corrected regular expression found in the site's comments. This is a nigh-one-line function for validating a string as an email address.

Initial Title
AS3 Email Validation

Initial Tags
form, email, post, validation

Initial Language
ActionScript 3