Count Characters Using Javascript

Posted on Posted in Javascript, Technology

The number of times, while implementing some applications like CMS we need to calculate the characters enter in the textbox. Javascript/jQuery makes it easy to calculate.

This post will help you to count the characters limit. Further to whom one can change by editing the code. Along with count, the code will restrict the user to write more characters in the text-area after reaching the limit.

<textarea rows="5" name="textBox" id="textBox"></textarea>
<span id="count"></span>
//script code
				var length = $(this).val().length;
				$("#count").text("Characters left: " + (100 - length)); //show the count
				if(length > 99){
					$('#textBox').attr("maxlength","99"); //add the attribute maxlength

Along with this do not forget to include jQuery file. While implementing this is any issue occurs, please ask your queries in comment box.