Contact Us

Scripts: Javascript :: Forms :: Library Article #20

Developer's Section

Javascript Email Address Validator
By: Erobo Team Member

Hire a Developer for Related Work / Installation | $55 hr
Rating:  | Rate It:   
Average Votes: (2608)

Create a simple javascript email validator for your forms.

In this tutorial we will learn how to validate an input field that requires a valid email address.
It is definitely sometimes very important to validate data before submitting it to a database to prevent errors and / or anomalies. The following is an explanation on how to install a simple javascript that can prevent users from entering information other than a valid email address into an input field.

Email Address Validator Example:

Email Address Validator:
Enter an Email Address:

Step 1: Create Javascript method
The following code snippet shows you how to create an email address validator using a regular expression:

 Code Snippet 1

<script language="Javascript">

function validateEmail(thisEmail) {
   var objRegExp  = 
   if(!objRegExp.test(thisEmail)) {
      alert("Please enter a valid Email Address")   
   else {
        alert("email is valid")
   return false

Step 2: Test using a simple form
Create a form and test the function:

 Code Snippet 2

<form name="check_email" >
<table border="1" style="border-collapse: collapse">
   <td colspan="3">Email Address Validator:</td>
   <td>Enter an Email Address:</td>
   <td><input type="text" name="myEmail" value="" ></td>
   <td><input type="button" value="validate"

See other Scripts in Forms


Submit Your Scripts:

If you would like to have your Javascripts published in this section please fill out
the form below:
*Your Name or Username:
Home Town:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]