function _clientside_validation_set_minmax_date in Clientside Validation 7
Same name and namespace in other branches
- 6 clientside_validation.module \_clientside_validation_set_minmax_date()
1 call to _clientside_validation_set_minmax_date()
- clientside_validation_webform_after_build_recurse in clientside_validation_webform/
clientside_validation_webform.module
File
- ./
clientside_validation.module, line 676 - Add client side validation to forms.
Code
function _clientside_validation_set_minmax_date($name, $title, $start_date, $end_date, &$js_rules, $message = '') {
$title = _clientside_validation_set_title($title);
if (isset($start_date) && $start_date !== '' && isset($end_date) && $end_date !== '') {
$js_rules[$name]['daterange'] = array(
$start_date,
$end_date,
);
if (empty($message)) {
$variables = array(
'message' => '!title field has to be between !min and !max.',
'placeholders' => array(
'!title' => $title,
'!min' => $start_date,
'!max' => $end_date,
),
'error_type' => 'daterange',
'element_name' => $name,
);
}
else {
$variables = array(
'message' => $message,
'error_type' => 'daterange',
'element_name' => $name,
);
}
$js_rules[$name]['messages']['daterange'] = theme('clientside_error', $variables);
}
elseif (isset($start_date) && $start_date !== '') {
$js_rules[$name]['datemin'] = $start_date;
if (empty($message)) {
$variables = array(
'message' => '!title field has to be greater than !min.',
'placeholders' => array(
'!title' => $title,
'!min' => $start_date,
),
'error_type' => 'datemin',
'element_name' => $name,
);
}
else {
$variables = array(
'message' => $message,
'error_type' => 'datemin',
'element_name' => $name,
);
}
$js_rules[$name]['messages']['datemin'] = theme('clientside_error', $variables);
}
elseif (isset($end_date) && $end_date !== '') {
$js_rules[$name]['datemax'] = $end_date;
if (empty($message)) {
$variables = array(
'message' => '!title field has to be smaller than !max.',
'placeholders' => array(
'!title' => $title,
'!max' => $end_date,
),
'error_type' => 'datemax',
'element_name' => $name,
);
}
else {
$variables = array(
'message' => $message,
'error_type' => 'datemax',
'element_name' => $name,
);
}
$js_rules[$name]['messages']['datemax'] = theme('clientside_error', $variables);
}
}