Advertisement
Guest User

Untitled

a guest
Sep 20th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. function validateEmail(email) {
  2. var re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  3. return re.test(email);
  4. }
  5.  
  6. /*
  7.  
  8. This regex allows the following email formats:
  9.  
  10. 1. prettyandsimple@example.com
  11. 2. very.common@example.com
  12. 3. disposable.style.email.with+symbol@example.com
  13. 4. other.email-with-dash@example.com
  14. 9. #!$%&'*+-/=?^_`{}|~@example.org
  15. 6. "()[]:,;@\\\"!#$%&'*+-/=?^_`{}| ~.a"@example.org
  16. 7. " "@example.org (space between the quotes)
  17. 8. üñîçøðé@example.com (Unicode characters in local part)
  18. 9. üñîçøðé@üñîçøðé.com (Unicode characters in domain part)
  19. 10. Pelé@example.com (Latin)
  20. 11. δοκιμή@παράδειγμα.δοκιμή (Greek)
  21. 12. 我買@屋企.香港 (Chinese)
  22. 13. 甲斐@黒川.日本 (Japanese)
  23. 14. чебурашка@ящик-с-апельсинами.рф (Cyrillic)
  24.  
  25. It's clearly versatile and allows the all-important international characters, while still enforcing the basic anything@anything.anything format. It will block spaces which are technically allowed by RFC, but they are so rare that I'm happy to do this.
  26.  
  27. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement