function date_text_validate in Date 5.2
Same name and namespace in other branches
- 5 date.inc \date_text_validate()
- 6.2 date_api_elements.inc \date_text_validate()
- 6 date_api_elements.inc \date_text_validate()
- 7.3 date_api/date_api_elements.inc \date_text_validate()
- 7 date_api/date_api_elements.inc \date_text_validate()
- 7.2 date_api/date_api_elements.inc \date_text_validate()
Validation for text input.
File
- ./
date_api_elements.inc, line 503 - 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) {
$value = date_text_input_value($element);
// If the field is empty and not required, set it to empty and return.
if (empty($value) && !$element['#required']) {
form_set_value($element, NULL);
return;
}
if (!empty($value)) {
form_set_value($element, $value);
}
else {
$error_field = implode('][', $element['#parents']);
form_set_error($error_field, t('A valid date is required for %title.', array(
'%title' => $element['#title'],
)));
}
}