Javascript examples for jQuery:Form Input
Allow user only to change first digit 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.9.1.js"></script> <script type="text/javascript"> $(window).load(function(){/*from www . j av a 2 s . co m*/ var elem="000"; $('input').val(elem); $(".text").keyup(function(){ console.log($(this).val()); $(this).val($(this).val().substring(0,1)+"00"); }); }); </script> </head> <body> <input type="text" value="" class="text"> </body> </html>