This javascript function will help you to limit/count the size of characters entered/typed in text area or in text box.
Features
You can limit the number of characters to be entered/typed in text area/textbox.
This javascript displays number of characters left to type in textbox.
Easy to specify the size/length of character counter/limiter.
Just copy the code in to your page and use it.
Simple and ease of use.
Preview
Downloads
Javascript Code
<!-- Script by hscripts.com --> <script type="text/javascript"> //Edit the counter/limiter value as your wish var count = "125"; //Example: var count = "175"; function limiter(){ var tex = document.myform.comment.value; var len = tex.length; if(len > count){ tex = tex.substring(0,count); document.myform.comment.value =tex; return false; } document.myform.limit.value = count-len; } </script> <!-- Script by hscripts.com -->
For customization of this script or any script development, mail to support@hscripts.com
Usage
He we have explained, how to use the count character javascript with the help of a form. The count value decreases when you type each character into textbox.
Copy the javascript code into the head part of your HTML page.
Copy the HTML code, This will create a textarea to enter the words/characters,Also a form field will be created which counts the character.
You can easily set the limit or counter as your wish. If you wish to restrict the user not to type more than 250 characters in text area/textbox change the count value as 250. This will set the length or size of text area or text box.
Example:var count = "250";
The java script function "limiter()" will limit the size or length of characters typed in textarea or text box.