Character Count In Textarea

WebSolutionStuff | Jul-08-2020 | Categories : Laravel PHP jQuery HTML

In this small tutorial i will explain you how to count characters from textarea, many time client's have requirments like they have to add some number of character in specific field and after that user can not add any data in this field , at that time we can dispaly count of character So, user can manage his/her content in text area.

here, we will add some piece of HTML code with textarea and in the bottom we will add Jquery code in script tag that's it.


<!DOCTYPE html>
    <title>Count Characters in Textarea Example -</title>
    <link href="" rel="stylesheet">
    <script src=""></script>
<div class="container">
    <h3 class="text-center" style="margin-bottom: 20px;">Count Characters in Textarea Example -</h3>
     <div class="col-md-8 col-md-offset-2">
        <textarea name="textarea" id="textarea" maxlength="300" rows="5" style="width: 100%" placeholder="Write Here"autofocus></textarea>
        <div id="count">
            <span id="current_count">0</span>
            <span id="maximum_count">/ 300</span>
<script type="text/javascript">
$('textarea').keyup(function() {    
    var characterCount = $(this).val().length,
        current_count = $('#current_count'),
        maximum_count = $('#maximum_count'),
        count = $('#count');    


And after that you will get output like below screen print.


Recommended Post
Featured Post