Email ID Validation

Posted by Arul44ece under JavaScript category on | Points: 40 | Views : 1623
Email ID Validation:

This is java script is used for validate then given email id format is correct or invalid format .

Example :

 <script type="text/javascript">

function validate()
var mailid = document.getElementById('<%=txtmailid.ClientID%>').value;

var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

if (mailid == "")

alert("Please Enter Mail ID");
return false;

if (!reg.test(mailid)) {
alert('Invalid Email Address');
return false;

Comments or Responses

Posted by: Rimi1289 on: 2/9/2013 Level:Starter | Status: [Member] | Points: 10

Your validation is open to SQL injections. Try the below code. Its tested and impregnable.


Its accepts Alpha Numeric values with 40 characters limit.


Login to post response