The following Script can be added to your webpage that includes form which would be asking for an email id. Note that it must be added to the head section of the webpage
Code:
<script type="text/javascript" src="email.js">
</script>
Then you must call it making use of the below code based on onclick or onsubmit action :
Code:
valid_email =
validateEmail(email_field,mandatory,messages);
The entered email id should pass in place of email_field in the code above. If its a mandatory field you must set the field as 1 else as 0.
You may also include an if statement in the validation code which would validate a mandatory email field:
Code:
if (!validateEmail(emailfield,1,0)) {
alert('invalid email id or please enter an email id');
return false;}
Hope it helps