AS3 Email Validation

/ Published in: ActionScript 3
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  1. */ syntax:
  2. if (!isValidEmail("")) {
  3. trace("FAIL");
  4. }
  5. */
  7. private function isValidEmail(email:String):Boolean {
  8. var emailExpression:RegExp = /([a-z0-9._-]+?)@([a-z0-9.-]+)\.([a-z]{2,4})/;
  9. return emailExpression.test(email);
  10. }


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.