function validatephone(sender, args) {
document.getElementById(“<%= customvalidate.ClientID %>”).innerHTML = “”;
var txt1 = document.getElementById(“<%= txtbox1.ClientID %>”).value;
var txt2 = document.getElementById(“<%= txtbox2.ClientID %>”).value;
var txt3 = document.getElementById(“<%= txtbox3.ClientID %>”).value;
if ((txt1 != “”) && (txt1 == 3)) {
if ((txt2 != “”) && (txt2 == 3)) {
if ((txt3 != “”) && (txt3 == 4)) {
return args.IsValid = true;
}
}
}
else if ((txt1 == “”) && (txt2 == “”) && (txt3 == “”)) {
document.getElementById(“<%= customvalidate.ClientID %>”).innerHTML = “Please enter home phone(### ### ####)”;
return args.IsValid = false;
}
else if ((txt1.length < 3) || (txt2.length < 3) || (txt3.length < 4) || (txt1 == “000”)) {
document.getElementById(“<%= customvalidate.ClientID %>”).innerHTML = “Please enter valid home phone”;
return args.IsValid = false;
}
else {
return args.IsValid = true;
}
}
Html Side
<asp:TextBox ID=”txtBox1″ onKeyUp=”txtchangedp3();”
MaxLength=”3″ CssClass=”phone_width” runat=”server”></asp:TextBox>
<asp:TextBox ID=”txtBox2″ onKeyUp=”txtchangedp4();”
MaxLength=”3″ CssClass=”phone_width” runat=”server”></asp:TextBox>
<asp:TextBox ID=”txtBox3″ onKeyUp=”trimstring(this.id,this.value);” CssClass=”phone_width1″ MaxLength=”4″ runat=”server”></asp:TextBox><br />
<asp:CustomValidator ID=”customvalidate” runat=”server” ValidationGroup=”Patient”
ClientValidationFunction=”validatePhone” Display=”Dynamic”></asp:CustomValidator>