You are here

function _clientside_validation_set_plain_text in Clientside Validation 7

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

Set validation rule for plain text fields

2 calls to _clientside_validation_set_plain_text()
clientside_validation_field_validation_regular in clientside_validation_field_validation/clientside_validation_field_validation.module
clientside_validation_webform_add_webform_validation in clientside_validation_webform/clientside_validation_webform.module
Support webform_validation

File

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

Code

function _clientside_validation_set_plain_text($name, $title, $allowed_tags, &$js_rules, $message = '', $negate = FALSE) {
  $title = _clientside_validation_set_title($title);
  $js_rules[$name]['plaintext']['tags'] = empty($allowed_tags) ? '' : $allowed_tags;
  $js_rules[$name]['plaintext']['negate'] = $negate;
  if (empty($message)) {
    $variables = array(
      'message' => empty($allowed_tags) ? '!title field can not contain any HTML tags' : '!title field can not contain any HTML tags exept !allowed',
      'placeholders' => array(
        '!title' => $title,
        '!allowed' => $allowed_tags,
      ),
      'error_type' => 'plaintext',
      'element_name' => $name,
    );
  }
  else {
    $variables = array(
      'message' => $message,
      'error_type' => 'plaintext',
      'element_name' => $name,
    );
  }
  $js_rules[$name]['messages']['plaintext'] = theme('clientside_error', $variables);
}