JQuery number only validation - Javascript jQuery

Javascript examples for jQuery:Number

Description

JQuery number only validation

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-2.2.4.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from   w  w  w  .ja v  a2s.c om*/
$('.alphaOnly').bind('keypress', function(event){
   var regex = new RegExp('\\d');
   console.log(regex.test(event.key));
});
    }

      </script> 
   </head> 
   <body> 
      <input type="text" class="alphaOnly">  
   </body>
</html>

Related Tutorials