You are here

function _clientside_validation_set_number in Clientside Validation 7

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

Set validation rule for positive or negative integer number fields.

3 calls to _clientside_validation_set_number()
clientside_validation_html5 in clientside_validation_html5/clientside_validation_html5.module
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 561
Add client side validation to forms.

Code

function _clientside_validation_set_number($name, $title, &$js_rules, $message = '') {
  $title = _clientside_validation_set_title($title);
  $js_rules[$name]['digits_negative'] = TRUE;
  if (empty($message)) {
    $variables = array(
      'message' => '!title field accepts only numbers.',
      'placeholders' => array(
        '!title' => $title,
      ),
      'error_type' => 'number',
      'element_name' => $name,
    );
  }
  else {
    $variables = array(
      'message' => $message,
      'error_type' => 'number',
      'element_name' => $name,
    );
  }
  $js_rules[$name]['messages']['digits_negative'] = theme('clientside_error', $variables);
}