function _clientside_validation_set_not_equal in Clientside Validation 7
Same name and namespace in other branches
- 6 clientside_validation.module \_clientside_validation_set_not_equal()
Set validation rule for fields that can not be equal to a value from an other field.
2 calls to _clientside_validation_set_not_equal()
- clientside_validation_webform_add_webform_validation in clientside_validation_webform/
clientside_validation_webform.module - Support webform_validation
- hook_clientside_validation_rule_alter in ./
clientside_validation.api.php - Some modules allow users to define extra validation rules defined in a hook. (e.g hook_webform_validation_validators()). To support these custom rules, clientside validation has its own hook, hook_clientside_validation_rule_alter. We had to use an…
File
- ./
clientside_validation.module, line 996 - Add client side validation to forms.
Code
function _clientside_validation_set_not_equal($name, $title, $elements, &$js_rules, $message = '', $webform = FALSE) {
$title = _clientside_validation_set_title($title);
$items = array(
'items' => array(),
);
foreach ($elements as $element) {
$items['items'][] = $element['name'];
if ($webform) {
$js_rules[$name]['notEqualTo'][] = 'input[name="' . $element['element_name'] . '"]';
}
else {
$js_rules[$name]['notEqualTo'][] = 'input[name="' . $element['form_key'] . '"]';
}
}
if (empty($message)) {
$variables = array(
'message' => '!title field has to be different from !firstone',
'placeholders' => array(
'!title' => $title,
'!firstone' => theme('item_list', $items),
),
'error_type' => 'notequalto',
'element_name' => $name,
);
}
else {
$variables = array(
'message' => $message,
'error_type' => 'notequalto',
'element_name' => $name,
);
}
$message = theme('clientside_error', $variables);
$js_rules[$name]['messages']['notEqualTo'] = $message;
}