Only numbers in input and detect "capsLock" on keypress - Javascript jQuery

Javascript examples for jQuery:Form Number Field

Description

Only numbers in input and detect "capsLock" on keypress

Demo Code

ResultView the demo in separate window

<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>

Related Tutorials