You are here

function element_validate_integer_positive in Drupal 7

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

Related topics

1 call to element_validate_integer_positive()
_element_validate_integer_positive in modules/field/field.module
DEPRECATED: Helper form element validator: integer > 0.
9 string references to 'element_validate_integer_positive'
hook_field_formatter_settings_form in modules/field_ui/field_ui.api.php
Specify the form elements for a formatter's settings.
hook_field_settings_form in modules/field_ui/field_ui.api.php
Add settings to a field settings form.
hook_field_widget_settings_form in modules/field_ui/field_ui.api.php
Add settings to a widget settings form.
search_admin_settings in modules/search/search.admin.inc
Menu callback: displays the search module settings page.
text_field_formatter_settings_form in modules/field/modules/text/text.module
Implements hook_field_formatter_settings_form().

... See full list

File

includes/form.inc, line 4408
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'],
    )));
  }
}