Regex to remove letters, symbols except numbers - Javascript RegExp

Javascript examples for RegExp:RegExp test

Description

Regex to remove letters, symbols except numbers

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.6.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from w  w  w .  j a  va 2  s  .  c  o m*/
$('input').keydown(function(){
   var self = $(this);
   var removedText = self.val().replace(/\D/, '');
   self.val(removedText);
});
    });

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

Related Tutorials