Last updated October 8, 2011. Created by jm.federico on October 8, 2011.
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

WYSIWYG

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.

#maxlength

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

Values: A positive number.

#maxlength_js

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 Drupal.org forums, or join #drupal-support in IRC.

Comments

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