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 realtime. 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.

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 *