over 8 years ago
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>
<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');
});
});
$(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
Can you help out the community by solving one of the following Javascript problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)