You are here

function _clientside_validation_set_plain_text in Clientside Validation 6

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

Set validation rule for plain text fields

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

File

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

Code

function _clientside_validation_set_plain_text($name, $title, $allowed_tags, &$js_rules, $message = '') {
  $title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
  $js_rules[$name]['plaintext'] = empty($allowed_tags) ? '' : $allowed_tags;
  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);
}