Since this seems so hard to do... An actual working example :)
Usage
HTML: <input type="text" onkeypress="return isNumericKeyPress(event.keyCode);" onpaste="isNumericPaste(this);" />
OR
ASP.NET: <asp:textbox ID="txtNumsOnly" runat="server" onkeypress="return isNumericKeyPress(event.keyCode);" onpaste="isNumericPaste(this);"></asp:textbox>
Demo
Type or paste something:
Samples
- 1!2@3#
- Test
- Test1
- 1a2b3c