You are here

function _clientside_validation_set_captcha in Clientside Validation 7

2 calls to _clientside_validation_set_captcha()
clientside_validation_regular in clientside_validation_form/clientside_validation_form.module
clientside_validation_webform_after_build_recurse in clientside_validation_webform/clientside_validation_webform.module

File

./clientside_validation.module, line 1334
Add client side validation to forms.

Code

function _clientside_validation_set_captcha($name, $title, $validate, &$js_rules, $message, $captcha_token) {
  $title = _clientside_validation_set_title($title);

  // Generate a token to validate the AJAX post values.
  $token = clientside_validation_generate_token($validate, $captcha_token);
  $js_rules[$name]['captcha'] = array(
    'captcha_validate' => $validate,
    'token' => $token,
    'captcha_token' => $captcha_token,
  );
  $variables = array(
    'message' => empty($message) ? 'Wrong answer for !title.' : $message,
    'placeholders' => empty($message) ? array(
      '!title' => $title,
    ) : array(),
    'error_type' => 'captcha',
    'element_name' => $name,
  );
  $js_rules[$name]['messages']['captcha'] = theme('clientside_error', $variables);
}