Email ID Validation

Arul44ece
Posted by Arul44ece under JavaScript category on | Points: 40 | Views : 1217
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
Hi,

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

ValidationExpression="^[a-zA-Z'.\s]{1,40}$"



Its accepts Alpha Numeric values with 40 characters limit.

Rimi

Login to post response