Contact Us

Scripts: Javascript :: Forms :: Library Article #5

Developer's Section

Limit TextArea Max Characters
By: Erobo Team Member

Hire a Developer for Related Work / Installation | $55 hr
Rating:  | Rate It:   
Average Votes: (2688)

Limit the number of Characters an user may enter per textarea.

In this tutorial we will learn how to limit the number of characters you are allowed to enter per textarea. To do this we will use a simple javascript that will be keeping track of the number of characters. Here is an example (100 characters max):

100 characters
To achive this we do the following:

 Code Snippet 1
<script language="JavaScript">

function textCounter(field,  maxlimit) {

     if (field.value.length > maxlimit) // if too long...trim it!
          field.value = field.value.substring(0, maxlimit);



<textarea name="comments" rows="5" cols="20" 



<div align="center"><small>100 characters</small></div>

See other Scripts in Forms


Submit Your Scripts:

If you would like to have your Javascripts published in this section please fill out
the form below:
*Your Name or Username:
Home Town:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]