Character Counter/Limiter Java Script

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

Type your data in Textarea / Textbox:
Character left:

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 -->


HTML Code

<!-- Script by hscripts.com -->
<form name="myform" METHOD=POST>
<textarea name=comment wrap=physical rows=3 cols=40 onkeyup=limiter()></textarea><br>
<script type="text/javascript">
document.write("<input type=text name=limit size=4 readonly value="+count+">");
</script>
</form>
<!-- Script by hscripts.com -->

  • Release Date - 19-07-2007
  • Get free version without ©copyright link for just $10/-
  • 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.
  •  <form name="myform" METHOD=POST>
    <textarea name=comment wrap=physical rows=3 cols=40 onkeyup=limiter()></textarea><br>
    <script type="text/javascript">
    document.write("<input type=text name=limit size=4 readonly value="+count+">");
    </script>
    </form>
  • 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.

License

Related Scripts

Free Javascript Scripts


Ask Questions

Ask Question