Javascript examples for DOM:Key Event
Get key code from key event
<html> <head> <script language="Javascript"> function isNumberKey(evt)/*ww w. ja v a 2 s. com*/ { var charCode = (evt.which) ? evt.which : event.keyCode; if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } </script> </head> <body> <input name="x" style="width:100%;height:40px;font-size:15px;" id="txtChar" onkeypress="return isNumberKey(event)" type="text"> </body> </html>