How to count total character in textbox using Jquery

In this tutorial you are going to see how to write a jQuery script which should display the number of characters entered in a textbox real time. This script could be very much useful if you want show the user how many characters the user has entered into a text box or textarea. You may also like How to limit character input in the textarea including count using Jquery and How to count same value comma separated string in php.

HTML Code

<textarea class="countCharacter"></textarea>
<div id="getcount"></div>

Jquery Code

<script type="text/javascript">
    $('.countCharacter').keyup(function(){
        var value  = $(this).val();
        var countvalue  = value.length;
        $('#getcount').html(countvalue);
    });
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *