function maxlength_validate_element in Maxlength 6.2
Element validate that checks the length of the text to see if it is valid.
1 string reference to 'maxlength_validate_element'
- _maxlength_format_element in ./
maxlength.module - Formats a form element to use maxlength value and use js. It's not moved to maxlength.inc because Form API calls it even when form_alter is not called
File
- ./
maxlength.module, line 222 - Enables a max length countdown on node body, title and CCK textfields.
Code
function maxlength_validate_element($element, &$form_state) {
$text = $element['#value'];
$text = str_replace("\r\n", '#', $text);
$text = str_replace(array(
"\n",
"\r",
), '#', $text);
if (drupal_strlen($text) > $element['#max_length_properties']['limit']) {
form_error($element, t('!field has exceeded its maximum number of characters (!limit).', array(
'!limit' => $element['#max_length_properties']['limit'],
'!field' => $element['#title'],
)));
}
}