Email Validation using JavaScript

Self-innovator
Posted by Self-innovator under JavaScript category on | Points: 40 | Views : 5228
Javascript
<script language="javascript" type="text/javascript">
function ValidateEmail(x)
{
var EmailExp=/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
if(x.value.match(EmailExp))
{
return true;
}
else
{
alert("Invalid mail id");
x.value="";
x.focus();
return false;
}
}</script>

cal on TextChanged in .aspx
<asp:textbox id="txtemail" runat="server" Onchange="validateEmail(this)">

Comments or Responses

Posted by: T.saravanan on: 12/26/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Kindly post your code inside the code tag.

Posted by: Klbaiju on: 3/30/2012 Level:Starter | Status: [Member] | Points: 10

Thanks friend it is working fine.

Regards

K L BAIJU

Login to post response