You are here

function _clientside_validation_set_blacklist in Clientside Validation 6

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

Set validation rule for fields that can not consist of one or more specific values

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

File

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

Code

function _clientside_validation_set_blacklist($name, $title, $values, &$js_rules, $message = '') {
  $js_rules[$name]['blacklist'] = $values;
  $title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
  if (empty($message)) {
    $variables = array(
      'message' => '!title field can not consist of following elements: !elements.',
      'placeholders' => array(
        '!title' => $title,
        '!elements' => implode(', ', $values),
      ),
      'error_type' => 'blacklist',
      'element_name' => $name,
    );
  }
  else {
    $variables = array(
      'message' => $message,
      'error_type' => 'blacklist',
      'element_name' => $name,
    );
  }
  $message = theme('clientside_error', $variables);
  $js_rules[$name]['messages']['blacklist'] = $message;
}