AS3 Checks a String to see if it is a Valid Email Format


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



Copy this code and paste it in your HTML
  1. var inputEmail:String = "[email protected]";
  2. trace("inputEmail: "+inputEmail);
  3. trace("isValidEmailAddress: "+isValidEmailAddress(inputEmail));
  4.  
  5. function isValidEmailAddress($str:String):Boolean {
  6. return (($str == findValidEmailAddress($str)) ? true : false);
  7. }
  8.  
  9. function findValidEmailAddress($str:String):String {
  10. var pattern:RegExp = /\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b/gi;
  11. var result:Object = pattern.exec($str);
  12. return ((result == null) ? "" : result[0]);
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.