W3cubDocs

/Drupal 7

function element_validate_integer_positive

element_validate_integer_positive($element, &$form_state)

Form element validation handler for integer elements that must be positive.

Related topics

File

includes/form.inc, line 4384
Functions for form and batch generation and processing.

Code

function element_validate_integer_positive($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'])));
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!form.inc/function/element_validate_integer_positive/7.x