Restrict to input field to accept only Alphabets without Space - Javascript jQuery

Javascript examples for jQuery:Form Input

Description

Restrict to input field to accept only Alphabets without Space

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.9.1.js"></script> 
  <script type="text/javascript">
jQuery(function($) {/*from   w  w  w. ja va 2s  .  c  o m*/
  $(".numbers-only").on("keyup blur", function() {
    $(this).val($(this).val().replace(/[^a-z]/ig, ''));
  });
});

      </script> 
 </head> 
 <body> 
  <input type="text" name="test" id="someid" class="numbers-only">  
 </body>
</html>

Related Tutorials