<script language="javascript" type="text/javascript">
function validate()
{
if (document.getElementById("<%=TextBox1.ClientID%>").value=="")
{
alert("Name can not be blank");
document.getElementById("<%=TextBox1.ClientID%>").focus();
return false;
}
if(document.getElementById("<%=TextBox2.ClientID %>").value=="")
{
alert("Email id can not be blank");
document.getElementById("<%=TextBox2.ClientID %>").focus();
return false;
}
var emailPat= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var emailid=document.getElementById("<%=TextBox2.ClientID %>").value;
var matchArray = emailid.match(emailPat);
if (matchArray == null)
{
alert("Your email address seems incorrect. Please try again.");
document.getElementById("<%=TextBox2.ClientID %>").focus();
return false;
}
if (document.getElementById("<%=TextBox3.ClientID%>").value=="")
{
alert("Contact Number can not be blank");
document.getElementById("<%=TextBox3.ClientID%>").focus();
return false;
}
var digits="0123456789";
var temp;
for (var i=0;i<document.getElementById("<%=TextBox3.ClientID %>").value.length;i++)
{
temp=document.getElementById("<%=TextBox3.ClientID%>").value.substring(i,i+1);
if (digits.indexOf(temp)==-1)
{
alert("Please enter correct Contact Number");
document.getElementById("<%=TextBox3.ClientID%>").focus();
return false;
}
}
if(document.getElementById("<%=TextBox5.ClientID %>").value=="")
{
alert("City can not be blank");
document.getElementById("<%=TextBox5.ClientID %>").value;
document.getElementById("<%=TextBox5.ClientID %>").focus();
return false;
}
if(document.getElementById("<%=TextBox6.ClientID %>").value=="")
{
alert("Password can not be blank");
document.getElementById("<%=TextBox6.ClientID %>").value;
document.getElementById("<%=TextBox6.ClientID %>").focus();
return false;
}
if(document.getElementById("<%=TextBox7.ClientID %>").value=="")
{
alert("Please Re-Enter Password ");
document.getElementById("<%=TextBox7.ClientID %>").value;
document.getElementById("<%=TextBox7.ClientID %>").focus();
return false;
}
return true;
}
</script>
Friday, November 25, 2011
How To validate Email ID a Form in ASP. Net.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment