Javascript examples for DOM HTML Element:Input Number
Is number key pressed in input text field box
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <input id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar"> <script type="text/javascript"> function isNumberKey(evt) {/*w w w . j a v a 2 s .c om*/ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; else return true; } </script> </body> </html>