JavaScript Email Validation

Internet addresses can be tricky things for users, especially new users, to type. You can help them by scanning the email address they enter and checking it for inproper form.

This script validates an email address with Regular Expressions



Email Address:


Script Source

<Under the head section>

<script language="javascript" type="text/javascript">

<!-- Hide from old browsers

re = /^\w+([\.-]?\w+)*@\w+([\.-]?w+(\.\w{2,3})+$/

function submitIt(myForm) {
if (re.test(myForm.emailAddr.value)) {
return true
alert("Invalid email address")
return false

// Script by
// If you are using this code please leave a link to
// End hiding script -->

<Under the body section>

<form onsubmit="return submitIt(this)" action="#">
<table border="0" cellspacing="8" cellpadding="8">
<td align="right" valign="top">
Email Address: </td>
<input name="emailAddr" type="text" size="50" />
<p><input type="reset" />&nbsp;<input type="submit" value="Submit" /></p> </td>


Please let me know if this script was helpful to you.