You are here

function date_text_validate in Date 6

Same name and namespace in other branches
  1. 5.2 date_api_elements.inc \date_text_validate()
  2. 5 date.inc \date_text_validate()
  3. 6.2 date_api_elements.inc \date_text_validate()
  4. 7.3 date_api/date_api_elements.inc \date_text_validate()
  5. 7 date_api/date_api_elements.inc \date_text_validate()
  6. 7.2 date_api/date_api_elements.inc \date_text_validate()

Validation for text input.

1 string reference to 'date_text_validate'
_date_api_elements in ./date_api_elements.inc
Implementation of hook_elements().

File

./date_api_elements.inc, line 426
Date API elements themes and validation. This file is only included during the edit process to reduce memory usage.

Code

function date_text_validate($element, &$form_state) {
  $form_values = $element['#value'];
  $value = date_text_input_value($element);
  if (!$element['#required'] && empty($value)) {
    form_set_value($element, NULL, $form_state);
  }
  elseif (!empty($value)) {
    form_set_value($element, $value, $form_state);
  }
  else {
    $error_field = implode('][', $element['#parents']);
    form_set_error($error_field, t('A valid date is required for %title.', array(
      '%title' => $element['#title'],
    )));
  }
}