Limit key press using regex for input field - Javascript jQuery

Javascript examples for jQuery:Form Event

Description

Limit key press using regex for input field

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.3.js"></script> 
      <script type="text/javascript" src="http://brianjaeger.com/docs/limitkeypress/jquery.limitkeypress.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//  ww w . j ava2s .  c o m
$('input').limitkeypress({ rexp: /^[A-Za-z]*$/ });
    });

      </script> 
   </head> 
   <body> 
      <input>  
   </body>
</html>

Related Tutorials