Javascript Email Validation

Cross browser Email Validation in JS

Javascript Tutorials

Email Validation

JavaScript for Email Address Validation

In forms when using email ID fields it is a good idea to use client side validation along with your programming language validation. The following example shows how you can validate an email address for a form. This javascript validation code is cross browser compatible (works for all browsers).

Email Validation Example

Example of email validation

Enter an Email Address :

Cut and Paste Code

Cut 'n' paste code for the above Example

JavaScript Code


Explanation of the Code

The JavaScript has two functions:

  • Function echeck is used to verify if the given value is a possible valid email address. This function simply verifies the following:
    1. It makes sure the email address has only one (@) and that it is not at the end or beginning of the email address.
    2. It makes sure the email address has atleast one (.) after the @.
    3. atleast one (.). It also makes sure that there are no spaces, extra '@'s or a (.) just before or after the @. It also makes sure that there

  • Function ValidateForm is used to make sure that the email field is not blank and that it is a valid email address on form submission.
Please like, +1, link to and share this SmartWebby resource if you found it helpful. Thanks!