php - Is there any way that the first character of a text box is either '+' or '-' by default -
i have text field on form gmt time. want users enter integers '+5' '+6' or '-6' or '-5' etc.
i want make easy users don't have write '+' or '-' there self. there should default option of '+' or '-' first character in text field.
i saw solutions making simple drop down in front , user can select there automatically appear in text box.
but want make more easy if other easy solution there.
will prefer using html5 if not jquery fine..
try one:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script> $(document).ready(function() { var num = 0; $('#txt1').keydown(function(e){ num += 1; if (e.keycode > 36 && e.keycode < 41) { if(num % 2){ $('#txt1').val('+'); }else{ $('#txt1').val('-'); } } }); }); </script> <input type="text" name="txt1" id="txt1" />
Comments
Post a Comment