Javascript E-mail 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. The script is cross browser compatibe (works for all browsers).
Example
Example of email validation
Cut and Paste Code
Cut 'n' paste code for the above Example
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 thus simply makes sure the email address has one
(@), 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
is atleast one (.) after the @.
- 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.