How to limit character input in the textarea including count using Jquery

I will explain how to use jQuery to limit number of characters in textarea(textbox) even copy and paste text or jQuery restrict textbox(textarea) length even copy and paste text in textbox show below code.

HTML Code

<textarea class="checkLimit" maxlength="100"></textarea>
<span id="count">100</span> Remaining Character

Jquery Code

<script language="javascript" type="text/javascript">
    var maxLength = 100;
    $('.checkLimit').keyup(function() {
      var textlen = maxLength - $(this).val().length;
      $('#count').text(textlen);
    });
</script>

Leave a Reply

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