Email Validation in ActionScript 3.0 using RegExp

You can use following function for validation of email using ActionScript 3.0 RegExp class.

/**
* @usage    Check if the given email address string is valid or not
* @param    email:String    Email address string that is to be checked
* @return    Boolean        Returns true if valid email, false otherwise
*/
public function isValidEmail(email:String):Boolean
{
var emailExpression:RegExp = /^[a-z][\w.-]+@\w[\w.-]+\.[\w.-]*[a-z][a-z]$/i;
return emailExpression.test(email);
}

Hope it would be useful to someone :)

Regards,

Naresh Khokhaneshiya

6 Responses to this post.

  1. Posted by drunkcat on December 17, 2008 at 10:14 pm

    was useful for me. Thanks!!

    Reply

  2. Posted by Kaiowas on April 29, 2009 at 11:15 pm

    It’s only working for a handful of email addresses
    when there’s a numeric char in the mail it’s not working :(

    Reply

  3. Posted by Ashok on May 9, 2009 at 11:41 am

    Thanks dude its very useful for me.

    Reply

  4. Try this one
    /^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/i

    Reply

Respond to this post