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.08k
    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:

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

    Javascript:

    1. $(document).ready(function() {
    2. var text_max = 99;
    3. $('#textarea_feedback').html(text_max + ' characters remaining');
    4.  
    5. $( "#target" ).keyup(function( event ) {
    6. var input = $("#target").val();
    7. $("#textarea").text(input );
    8. var text_length = $('#target').val().length;
    9. var text_remaining = text_max - text_length;
    10.  
    11. $('#textarea_feedback').html(text_remaining + ' characters remaining');
    12. });
    13. });


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

    1. <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
Reset Password
Fill out the form below and reset your password: