Prevent Special character from typing in for NAME input box - Javascript jQuery

Javascript examples for jQuery:Form Input

Description

Prevent Special character from typing in for NAME input box

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-2.1.0.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from  w  w w. j a  v a  2  s  . c  o  m*/
$(function(){
    $('input, textarea').keyup( function(){
        var inputs = $(this).val();
        $(this).val(inputs.replace(/[^a-z0-9\s]/gi, ''));
    });
});
    });

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

Related Tutorials