function _clientside_validation_set_checkboxgroup_minmax in Clientside Validation 6
Same name and namespace in other branches
- 7 clientside_validation.module \_clientside_validation_set_checkboxgroup_minmax()
Set validation rule for checkboxes.
4 calls to _clientside_validation_set_checkboxgroup_minmax()
- clientside_validation_cck in clientside_validation_form/
clientside_validation_form.module - 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 930 - Add client side validation to a webform.
Code
function _clientside_validation_set_checkboxgroup_minmax($name, $title, $id, &$js_rules, $min = 1, $max = 99) {
$title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
$js_rules[$name]['checkboxgroupminmax'] = array(
$min,
$max,
$id,
);
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,
);
}
$variables = array(
'message' => $message,
'placeholders' => $placeholders,
'error_type' => 'required',
'element_name' => $name,
);
$js_rules[$name]['messages']['checkboxgroupminmax'] = theme('clientside_error', $variables);
}