<title>Allow only number in Textbox</title>
<input type="text" onkeypress="allowNumbers(event)">
var code = (e.which) ? e.which : e.keyCode;
if (code > 31 && (code < 48 || code > 57))
Explanation of the above example
The ASCII table is shown below for your reference.
Conclusion:- I hope the above illustration will help you to understand the overview. If there is any doubt then please leave a comment below.
Originally published at https://pbphpsolutions.com on June 15, 2022.