Email Format Validation

To Check if email is in valid form we can use this script.

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Email Validation Form</title>
  5. <script>
  6. function emailValidate(strEmail)
  7. {
  8. validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  9.  
  10. if (strEmail.search(validRegExp) == -1)
  11. {
  12. alert("Invalid e-mail address");
  13. return false;
  14. }
  15. }
  16. </script>
  17. </head>
  18.  
  19. <body>
  20. <form id="form1" name="form1" method="post" action="">
  21. <label>
  22. <input type="text" name="email" id="email" />
  23. </label>
  24. <p>
  25. <label>
  26. <input type="submit" name="button" id="button" value="Submit"
  27. onclick="return emailValidate(document.form1.email.value)" />
  28. </label>
  29. </p>
  30. </form>
  31. </body>
  32. </html>

Live Example

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.