Javascript examples for jQuery:Form Number Field
Only numbers in input and detect "capsLock" on keypress
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> <script type="text/javascript"> $(window).load(function(){// w ww.ja v a 2s .c om $('input').on('input', function (e) { this.value = this.value.replace(/\D/g,''); }); }); </script> </head> <body> <input type="text" name="test"> </body> </html>