function _clientside_validation_set_specific_value in Clientside Validation 6
Same name and namespace in other branches
- 7 clientside_validation.module \_clientside_validation_set_specific_value()
Set validation rule for fields that must be equal to a specific value.
2 calls to _clientside_validation_set_specific_value()
- 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
File
- ./
clientside_validation.module, line 762 - Add client side validation to a webform.
Code
function _clientside_validation_set_specific_value($name, $title, $value, &$js_rules, $message = '', $case_sensitive = TRUE) {
$js_rules[$name]['oneOf'] = array(
'values' => array(
$value,
),
'caseSensitive' => $case_sensitive,
);
$title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
if (empty($message)) {
$variables = array(
'message' => '!title field has to be one of the following values: !values.',
'placeholders' => array(
'!title' => $title,
'!values' => implode(', ', $value),
),
'error_type' => 'specific value',
'element_name' => $name,
);
}
else {
$variables = array(
'message' => $message,
'error_type' => 'specific value',
'element_name' => $name,
);
}
$message = theme('clientside_error', $variables);
$js_rules[$name]['messages']['oneOf'] = $message;
}