function _clientside_validation_set_equal in Clientside Validation 7
Same name and namespace in other branches
- 6 clientside_validation.module \_clientside_validation_set_equal()
Set validation rule for required fields that must equal a value from an other field.
2 calls to _clientside_validation_set_equal()
- clientside_validation_webform_add_webform_validation in clientside_validation_webform/
clientside_validation_webform.module - Support webform_validation
- _clientside_validation_set_fapi_validation in clientside_validation_fapi/
clientside_validation_fapi.module - Set fapi validation.
File
- ./
clientside_validation.module, line 964 - Add client side validation to forms.
Code
function _clientside_validation_set_equal($name, $title, $value, &$js_rules, $message = '', $webform = FALSE) {
$title = _clientside_validation_set_title($title);
if ($webform) {
$js_rules[$name]['equalTo'] = ':input[name=\'submitted[' . $value['form_key'] . ']\']';
}
elseif (is_array($value)) {
$js_rules[$name]['equalTo'] = ':input[name=\'' . $value['element_name'] . '\']';
}
else {
$js_rules[$name]['equalTo'] = ':input[name=\'' . $value . '\']';
}
if (empty($message)) {
$variables = array(
'message' => is_array($value) ? '!title field has to be equal to !firstone.' : 'Field values must match',
'placeholders' => is_array($value) ? array(
'!title' => $title,
'!firstone' => $value['name'],
) : array(),
'error_type' => 'equalto',
'element_name' => $name,
);
}
else {
$variables = array(
'message' => $message,
'error_type' => 'plaintext',
'element_name' => $name,
);
}
$js_rules[$name]['messages']['equalTo'] = theme('clientside_error', $variables);
}