You are here

function _clientside_validation_set_equal in Clientside Validation 6

Same name and namespace in other branches
  1. 7 clientside_validation.module \_clientside_validation_set_equal()

Set validation rule for required fields that must equal a value from an other field.

1 call to _clientside_validation_set_equal()
clientside_validation_webform_add_webform_validation in clientside_validation_webform/clientside_validation_webform.module
Support webform_validation

File

./clientside_validation.module, line 717
Add client side validation to a webform.

Code

function _clientside_validation_set_equal($name, $title, $value, &$js_rules) {
  $title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
  $js_rules[$name]['equalTo'] = ':input[name=\'submitted[' . $value['form_key'] . ']\']';
  $variables = array(
    'message' => '!title field has to be equal to !firstone.',
    'placeholders' => array(
      '!title' => $title,
      '!firstone' => $value['name'],
    ),
    'error_type' => 'equalto',
    'element_name' => $name,
  );
  $js_rules[$name]['messages']['equalTo'] = theme('clientside_error', $variables);
}