You are here

function maxlength_node_title_validate in Maxlength 7.3

Checks if the title field of the node is not set to more then 255 chars, because Drupal Core cannot handle this.

1 string reference to 'maxlength_node_title_validate'
maxlength_form_node_type_form_alter in ./maxlength.module
Implements hook_form_node_type_alter().

File

./maxlength.module, line 296
Limit the number of characters in textfields and textareas and shows the amount of characters left.

Code

function maxlength_node_title_validate($element, &$form_state, $form) {
  if (!empty($element['#value']) && !is_numeric($element['#value'])) {
    form_error($element, t('This field needs to be numeric'));
  }
  if (!empty($element['#value']) && is_numeric($element['#value']) && $element['#value'] > 255) {
    form_error($element, t('Note titles can be maximum 255 characters long.'));
  }
}