Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 validaion control which is used to validate mobile number below is source code
XML
<asp:TextBox ID="txtMobileNumber1" runat="server" Width="200px"></asp:TextBox>

<asp:RegularExpressionValidator ID="revMobileNumber1" runat="server"
ControlToValidate="txtMobileNumber1" ErrorMessage="Please Enter Number Only"ForeColor="Red" ValidationExpression="^\d+$"></asp:RegularExpressionValidator>

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"  runat="server"ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}" ErrorMessage="Mobile Number should be 10 Digit" ControlToValidate="txtMobileNumber1"></asp:RegularExpressionValidator>


I want if user enter charcater than it display first error "please enter number" and second error should not display "Mobile Number should be 10 digit".but in my case it display both error message.i want only one message at time. i have only one button control.
Posted

It's quite tough to Judge the validator events, which will fire first. Rather you can go for Javascript using same RegularExpression.


--Amit
 
Share this answer
 
Why don't you try custom validator and write your own javascript function and put your logic.
And show the error message as per your requirement.
 
Share this answer
 
Comments
Manohar Khillare 5-Feb-13 2:38am    
Is there way to display error in same place

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900