Javascript examples for DOM HTML Element:Form Event
Set cursor position in a input box
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <input type="text" onkeypress="acceptText()"> <script type="text/javascript"> function acceptText(){/*from www .jav a 2s. co m*/ console.log(event.charCode); if(event.charCode < 48 || event.charCode>57) event.preventDefault(); } </script> </body> </html>