Javascript examples for jQuery:Form Input
Restrict characters in input field
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> <script type="text/javascript"> $(window).load(function(){/*from ww w . j av a2 s . c om*/ $('.input').keyup(function () { if (!this.value.match(/[0-9]/)) { this.value = this.value.replace(/[^0-9]/g, ''); } }); }); </script> </head> <body> <input class="input" maxlength="1" type="text" autocomplete="off"> </body> </html>