-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Laryn - CEDC.org edited this page Nov 12, 2019
·
2 revisions
Welcome to the maxlength wiki!
MaxLength works in combination with Webform Validation. Create a "maximum length" validator and MaxLength will automatically kick in.
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
$form['description'] = array(
'#required' => '1',
'#description' => t('Max. 500 Characters'),
'#type' => 'textarea',
'#maxlength' => 500,
'#maxlength_js' => TRUE,
'#attributes' =>array(
'maxlength_js_label' => '@remaining characters left.',
),
'#title' => t('Detailed Description (required)'),
);