Description: This useful form validation script lets you add a custom "maxlength" attribute to INPUT type="text" and TEXTAREA elements, so users are prevented from entering more characters into these fields than the designated number. Inspired by Twitter's input box, it can optionally show the number of characters remaining for a field as the user types while displaying this info in different colors depending on how close the user is to the limit.

Example :

Enter your hobbies (<50 characters)

Enter your postal code (<6 characters)


Step 1: Simply insert the below in the head section of your page:

Be sure to download maxlength.js (right click and select "Save As"), the external file referenced by the above code.

Step 2: Simply insert the below in the body section of your page: