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>
0 Comment(s)