Disable symbols and non-letters in input field - Javascript jQuery

Javascript examples for jQuery:Form Input

Description

Disable symbols and non-letters in 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.4.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from ww w.  ja v  a 2 s  .  c  om*/
$('#ItemName').keypress(function (e) {
    var txt = String.fromCharCode(e.which);
    if (!txt.match(/[A-Za-z0-9&.]/)) {
        return false;
    }
});
    });

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

Related Tutorials