Last updated October 8, 2011. Created on October 8, 2011.
Edited by jm.federico. Log in to edit this page.

D7: 7.x-3.x

Maxlength creates a new Form Property: #maxlength_js which in conjunction with #maxlength will enforce, via JavaScript, the maxlength of a textfield, a textarea, or a text_format and will show the number of characters left.

UI Usage

When editing the a text field widget's settings, you can set the character limit to be controlled with Maxlength. Widgets currently accepted are:

  • Text area (multiple rows)
  • Text area with a summary
  • Text field


Module is compatible with tinyMCE and CKEditor using the wysiwyg module

Code (api?) Usage

Whether when creating a form or when altering one, put both #maxlength and #maxlength_js properties on the elements you want to control.


Description: The maximum amount of characters to accept as input.

Values: A positive number.


Used by: textfield, textarea, text_format

Description: Indicates whether or not the field should have a reverse character counter.

Values: TRUE or FALSE

Looking for support? Visit the forums, or join #drupal-support in IRC.


myselfhimself’s picture

I had been using maxlength_js on my site so far. Disabling it and installing maxlength in place seems to make the characters limit continue working. Is maxlength truly a drop-in replacement for maxlength_js ? Are they any upgrade path instructions from maxlength_js to maxlength for making things properly and avoid a break in further maxlength updates or so?
Thanks in advance!