html - display length of textarea value out of max -


i want have text area shows how wrote in , displays on bottom right of textarea(inside textbox ) out of max length of value. cant find how so. thanks.

you can achieve using jquery following simple code:

var thecounter = $('#textarealength'),     textarea = $('#mytextarea'),     maxlength = textarea.attr('length');  thecounter.text('0 / '+maxlength); thecounter.css({       'top': (textarea.offset().top + textarea.height()) - thecounter.height(),     'left': (textarea.offset().left + textarea.width()) - thecounter.width() });  textarea.on('keydown', function() {       var thelength = $(this).val().length;     thecounter.text($(this).val().length+' / '+maxlength)               .css({                     'left': (textarea.offset().left + textarea.width()) - thecounter.width()               }); }); 

obviously you'll need put in logic prevent further action occuring if max length met, should pretty self-explanatory.

i've put jsfiddle you.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -