function _clientside_validation_set_specific_value in Clientside Validation 7
Same name and namespace in other branches
- 6 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_field_validation_regular in clientside_validation_field_validation/
clientside_validation_field_validation.module - clientside_validation_webform_add_webform_validation in clientside_validation_webform/
clientside_validation_webform.module - Support webform_validation
File
- ./
clientside_validation.module, line 1030 - Add client side validation to forms.
Code
function _clientside_validation_set_specific_value($name, $title, $value, &$js_rules, $message = '', $case_sensitive = TRUE, $negate = FALSE) {
if (!is_array($value)) {
$value = array(
$value,
);
}
$js_rules[$name]['oneOf'] = array(
'values' => $value,
'caseSensitive' => $case_sensitive,
'negate' => $negate,
);
$title = _clientside_validation_set_title($title);
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;
}