I have a textbox for adding a phone number or editing the phone number. I need to validate the text box such that it accepts only numbers on key pressed
I could find solutions for windows form applications
yash
run following
<form>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="TextBox1" ErrorMessage="*" ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}"></asp:RegularExpressionValidator> </form>
Try this.....
onkeydown="if (window.event.keyCode < 47 && window.event.keyCode > 58){ return false; }"