You are here

function _clientside_validation_set_blacklist in Clientside Validation 7

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

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

3 calls to _clientside_validation_set_blacklist()
clientside_validation_field_validation_regular in clientside_validation_field_validation/clientside_validation_field_validation.module
clientside_validation_regular in clientside_validation_form/clientside_validation_form.module
clientside_validation_webform_add_webform_validation in clientside_validation_webform/clientside_validation_webform.module
Support webform_validation

File

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

Code

function _clientside_validation_set_blacklist($name, $title, $values, &$js_rules, $message = '', $negate = FALSE) {
  $js_rules[$name]['blacklist']['values'] = $values;
  $js_rules[$name]['blacklist']['negate'] = $negate;
  $title = _clientside_validation_set_title($title);
  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;
}