You are here

function _select2_element_validate_integer_positive_or_zero in Select 2 7

Validate values are positive integers.

1 string reference to '_select2_element_validate_integer_positive_or_zero'
select2_settings_form in pages/select2.admin.inc
Impelemnts hook_form().

File

./select2.module, line 1134
Main file for Select2 module.

Code

function _select2_element_validate_integer_positive_or_zero($element, &$form_state) {
  $value = $element['#value'];
  if ($value !== '' && (!is_numeric($value) || intval($value) != $value || $value < 0)) {
    form_error($element, t('%name must be a positive integer.', array(
      '%name' => $element['#title'],
    )));
  }
}