Force TextBox to only accept strings - Javascript jQuery

Javascript examples for jQuery:String

Description

Force TextBox to only accept strings

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.7.1.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//from www .j a va2 s  .co  m
$('#stringonly').keyup(function(){
    var _this = $(this);
    _this.val(_this.val().replace(/[0-9]/ig,""));
});
    });

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

Related Tutorials