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("my_NON_email.com")) {
  3. trace("FAIL");
  4. }
  5. */
  6.  
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.