You are here

function finder_text_element_validate in Finder 7.2

Validation callback for text element.

1 string reference to 'finder_text_element_validate'
finder_text_element in plugins/element_handler/text.inc
Element callback.

File

plugins/element_handler/text.inc, line 138
The finder text element handler plugin.

Code

function finder_text_element_validate($element, &$form_state) {
  if (isset($element['#minlength']) && $element['#minlength'] && $element['#value'] && drupal_strlen($element['#value']) < $element['#minlength']) {
    form_error($element, t('%title requires a minimum of %char characters.', array(
      '%title' => $element['#title'],
      '%char' => $element['#minlength'],
    )));
  }
  if (isset($element['#maxlength']) && $element['#maxlength'] && $element['#value'] && drupal_strlen($element['#value']) > $element['#maxlength']) {
    form_error($element, t('%title allows a maximum of %char characters.', array(
      '%title' => $element['#title'],
      '%char' => $element['#maxlength'],
    )));
  }
}