function _clientside_validation_set_checkboxgroup_minmax in Clientside Validation 7
Same name and namespace in other branches
- 6 clientside_validation.module \_clientside_validation_set_checkboxgroup_minmax()
Set validation rule for checkboxes.
3 calls to _clientside_validation_set_checkboxgroup_minmax()
- clientside_validation_regular in clientside_validation_form/
clientside_validation_form.module - clientside_validation_webform_add_webform_validation in clientside_validation_webform/
clientside_validation_webform.module - Support webform_validation
- clientside_validation_webform_after_build_recurse in clientside_validation_webform/
clientside_validation_webform.module
File
- ./
clientside_validation.module, line 1206 - Add client side validation to forms.
Code
function _clientside_validation_set_checkboxgroup_minmax($name, $title, $id, &$js_rules, $message = '', $min = 1, $max = 99) {
$title = _clientside_validation_set_title($title);
$js_rules[$name]['checkboxgroupminmax'] = array(
$min,
$max,
$id,
);
if ($message == '') {
if ($min == 1 && $max == 99) {
$message = '!title field is required.';
$placeholders = array(
'!title' => $title,
);
}
if ($min == 0 && $max != 99) {
$message = 'You can select no more than !max values for !title.';
$placeholders = array(
'!title' => $title,
'!max' => $max,
);
}
if ($min != 1 && $max == 99) {
$message = 'You must select at least !min values for !title.';
$placeholders = array(
'!title' => $title,
'!min' => $min,
);
}
if ($min > 0 && $max != 99) {
$message = 'You must select between !min and !max values for !title.';
$placeholders = array(
'!title' => $title,
'!min' => $min,
'!max' => $max,
);
}
}
else {
$placeholders = array();
}
$variables = array(
'message' => $message,
'placeholders' => $placeholders,
'error_type' => 'required',
'element_name' => $name,
);
$js_rules[$name]['messages']['checkboxgroupminmax'] = theme('clientside_error', $variables);
}