I inserted a comaper validator in my page linked with a text box to just get numbers as input.
Here's the code,
<asp:CompareValidator ID="cv" runat="server" ControlToValidate="ContactNumber" Type="Integer" Display="Dynamic" Operator="DataTypeCheck" ErrorMessage="Input Only Numbers" SetFocusOnError="True" />
But when I input number like xxxx-xxxxxxx (i.e with a - in between) and then change the texbox, The error message just appears for a blink of an eye and vanishes.
Can anyone help in making it stay? Or suggest any other way to just get numbers 0-9 input.
P.S: I have already applied onkeypress="if(isNaN(String.fromCharCode(event.keyCode))) return false;" on my textbox, but the problem occurred when client copy pasted the number with - in between.
Help guys!