This solution works in both IE and Netscape/Mozilla.
Try it here! Just type in the text box below. Note that digits are allowed and alphabetic characters are not allowed. Observe, too, that arrow keys and backspace are allowed so that you can still edit what you type.
Back to Top
Example: Allow only numbers/digits in TextBox
<INPUT id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar">