You are here

function uc_store_validate_uc_quantity in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_store/uc_store.module \uc_store_validate_uc_quantity()

Form element validation handler for #type 'uc_quantity'.

1 string reference to 'uc_store_validate_uc_quantity'
uc_store_element_info in uc_store/uc_store.module
Implements hook_element_info().

File

uc_store/uc_store.module, line 544
Contains global Ubercart functions and store administration functionality.

Code

function uc_store_validate_uc_quantity(&$element, &$form_state) {
  if (!preg_match('/^\\d+$/', $element['#value'])) {
    form_error($element, t('The quantity must be an integer.'));
  }
  elseif (empty($element['#allow_zero']) && !$element['#value']) {
    form_error($element, t('The quantity cannot be zero.'));
  }
}