function opening_hours_admin_blocked_day_add_form_validate in Opening hours 7
Same name and namespace in other branches
- 6 includes/opening_hours.admin.inc \opening_hours_admin_blocked_day_add_form_validate()
Validation handler for blocked day add form.
File
- includes/
opening_hours.admin.inc, line 77 - Administration page for opening hours.
Code
function opening_hours_admin_blocked_day_add_form_validate(&$form, &$form_state) {
$matches = array();
$date = trim($form_state['values']['date']);
if (!preg_match('/^(20\\d\\d-[01]\\d-[0-3]\\d)/', $date, $matches)) {
form_set_error('date', t('Invalid date. Must be in Y-m-d format, eg. 2011-12-28'));
}
// Store the sanitized value as the date.
$form_state['values']['date'] = $matches[1];
}