(Tips) Adding A Javascript Counter To Your Drupal Forms

Tips : Adding A Javascript Counter To Your Drupal Forms

if you want to add a javascript counter (n characters remaining) to your drupal forms, you can do the following ; (jquery code based very heavily on the jquery tricks on reindel.com)

1. add two new classes to your text area

add two new css classes to your text area i.e. countdown and a limit specification (for how many characters you want to limit to.
<textarea cols="40" rows="4" name="title" id="edit-title"  value="" class="form-text required countdown limit_100_"></textarea>

2. create a span where you want your n remaining characters to go

<textarea cols="40" rows="4" name="title" id="edit-title"  value="" class="form-text required countdown limit_100_"></textarea>
<br />
<span class="remaining"><!-- --></span>

| Read more

Courtesy : Johnandcailin.com