<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.
Thursday, November 24, 2011
Limit no of character in textbox with count in Asp.net using javascript
<script type="text/javascript">
{if (field.value.length > maxlimit)
{return false;</script>
}
}function textCounter(field,maxlimit)
protected void Page_Load(object sender, EventArgs e)"onkeydown", "return textCounter(this, 5)");"onkeyup", "return textCounter(this, 5)");"onmousedown","return textCounter(this, 5)");"onmouseup","return textCounter(this, 5)");"onblur", "return textCounter(this, 5)");
{
txtmaxlen.Attributes.Add(
txtmaxlen.Attributes.Add(
txtmaxlen.Attributes.Add(
txtmaxlen.Attributes.Add(
txtmaxlen.Attributes.Add(
}
{if (field.value.length > maxlimit)
{return false;</script>
}
}function textCounter(field,maxlimit)
protected void Page_Load(object sender, EventArgs e)"onkeydown", "return textCounter(this, 5)");"onkeyup", "return textCounter(this, 5)");"onmousedown","return textCounter(this, 5)");"onmouseup","return textCounter(this, 5)");"onblur", "return textCounter(this, 5)");
{
txtmaxlen.Attributes.Add(
txtmaxlen.Attributes.Add(
txtmaxlen.Attributes.Add(
txtmaxlen.Attributes.Add(
txtmaxlen.Attributes.Add(
}
Wednesday, November 16, 2011
Spaces are not allowed!
<asp:RegularExpressionValidator ID="rev" runat="server" ControlToValidate="txtBox"
ErrorMessage="Spaces are not allowed!" ValidationExpression="[^\s]+" />
<asp:RequiredFieldValidator ID="rfv" runat="server" ControlToValidate="txtBox"
ErrorMessage="Value can't be empty" />
ErrorMessage="Spaces are not allowed!" ValidationExpression="[^\s]+" />
<asp:RequiredFieldValidator ID="rfv" runat="server" ControlToValidate="txtBox"
ErrorMessage="Value can't be empty" />
Subscribe to:
Posts (Atom)