jquery - Displaying input character limit inside of the input? -
i have set character limit function displays how many more characters input accept. move output within input
, floated right, seen below. best way accomplish this?
example:
<input name="name" placeholder="name" maxlength="120" /> <div class="remaining"></div> function characterlimit() { var remaining = 120 - $('input').val().length; $('.remaining').text(remaining); } characterlimit(); $('input').keyup(function() { characterlimit(); });
it's done killing original borders on input , make fake border(wrapper div) surrounds input , number.
here example comment http://jsfiddle.net/9q319a4c/2/
<div class="input"> <input name="name" placeholder="name" /> <span class="remaining"></span> </div>
css
input { border: none; } .input { border: 1px solid #ccc; float: left; }
Comments
Post a Comment