Wednesday, February 24, 2016

Count and display number of characters in a textbox using Javascript & Jquery

We could do this in jQuery, assuming we want the character count displayed in a div with id="characters"


<textarea></textarea>
<span id="characters"><span>
$('textarea').keyup(updateCount);
$('textarea').keydown(updateCount);

function updateCount() {
    var cs = $(this).val().length;
    $('#characters').text(cs);
}
This is the most easiest way to do it.

Total Pageviews