Google is full of this kind of questions but I guess my problem is little bit different.
What make is different is here I used masked input I included jquery.maskedinput-1.2.2.js and jquery-1.7.2.min.js to use masked inputs. Code for masking is
$(document).ready(
function () {
$("#txtPhoneNo").mask("?(999) 999-9999");
});
but it is not validating length of input so I wrote javascript for that and used 'CustomValidator'as follows.
function isPhoneNumberValid(sender, args) {alert("l");
if (args.value.length < 2)
args.isValid = false;
}
alert("l"); itself will tell you that I just want to see whether this js function fires or not.
code for textbox and CustomValidator is as follow.
<asp:TextBox ID="txtPhoneNo" runat="server" CssClass="textbox3" size="60" Width="350px"
TabIndex="4" ClientIDMode="Static"></asp:TextBox>
<span style="font-size: 12px;">(000-000-0000)</span>
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Phone number is not valid"
ClientValidationFunction="isPhoneNumberValid" Font-Size="9pt" ForeColor="Red" ControlToValidate="txtPhoneNo"></asp:CustomValidator>
NOTE
Here in textbox ClientIDMode="Static" is used which may be problem.
PROBLEM
Problem is my js function is not firing at all. It must show alert if length of text is less than 2 but its not showing, instead making postback.
Could anyone help me out. Thanks
isPhoneNumberValidin textboxvalueandisValidcasing too from your reference ?alert()before thatvaluewithValueandisValidwithIsValid