Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Learn how to create a comment with word limit using jQuery

    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2
    • 0
    • 1.06k
    Comment on it

    Hii,
     In this blog, I am going to share an example in which i have created a comment box using few html tags like input box and text area and i have used jquery to set the word limit and to count the number of characters typed.
    Go through the example below and learn how to create a comment with word counter and to set word limit using jQuery. 

    HTML:

    <input id="target" type="text" style="visiblity:hidden;" maxlength="99">
    <textarea id="textarea" rows="8" cols="30" maxlength="99" readonly="" ></textarea>

    Javascript:

    $(document).ready(function() {
      var text_max = 99;
      $('#textarea_feedback').html(text_max + ' characters remaining');
    
      $( "#target" ).keyup(function( event ) {
       var input = $("#target").val();
        $("#textarea").text(input );
        var text_length = $('#target').val().length;
        var text_remaining = text_max - text_length;
    
        $('#textarea_feedback').html(text_remaining + ' characters remaining');
      });
    });


    Link: Must include this external jquery library link in your file

    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>

     

    Learn how to create a comment with word limit using jQuery

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: