You are here

function element_validate_integer in Drupal 7

Form element validation handler for integer elements.

Related topics

1 call to element_validate_integer()
_element_validate_integer in modules/field/field.module
DEPRECATED: Helper form element validator: integer.
2 string references to 'element_validate_integer'
form_process_weight in includes/form.inc
Expands a weight element into a select element.
_poll_choice_form in modules/poll/poll.module

File

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

Code

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