Javascript examples for DOM Event:onkeydown
Handle OnKeyDown event and use String.FromCharCode to get key code
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function PreventDigits(evt) {// w w w .j a v a 2 s . c o m evt = evt || window.event; var keyCode = evt.keyCode || evt.which;7 var num = parseInt(String.fromCharCode(keyCode), 10); return isNaN(num); } </script> </head> <body> <input type="text" onkeypress="return PreventDigits(event);"> </body> </html>