E-mail validation in javascript

Manna
Posted by Manna under JavaScript category on | Points: 40 | Views : 1780
<script type="text/javascript">
function fun_CheckEmailID(obj)
{
var email_Value = Trim(obj.value);

if (email_Value != "")
{
return Email_Single_NonMand(obj);
}
else
{
return true;
}


}

function Email_Single_NonMand(objval)
{
var emailfilter = /^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
var objval1 = Trim(objval.value);
var returnval = emailfilter.test(objval1);
if (returnval == false)
{
alert("Please enter a valid email address.")
document.getElementById(objval.id).value = "";
return false;
}
}

</script>

<asp:TextBox ID="txt_email" runat="server" MaxLength="50" onblur="return fun_CheckEmailID(this);"> </asp:TextBox>

Comments or Responses

Login to post response