You are here

function uc_attribute_option_form_validate in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_attribute/uc_attribute.module \uc_attribute_option_form_validate()
  2. 6.2 uc_attribute/uc_attribute.admin.inc \uc_attribute_option_form_validate()

Validates number formats.

See also

uc_attribute_option_form()

uc_attribute_option_form_submit()

File

uc_attribute/uc_attribute.admin.inc, line 452
Attribute administration menu items.

Code

function uc_attribute_option_form_validate($form, &$form_state) {
  $pattern = '/^-?\\d*(\\.\\d*)?$/';
  $price_error = t('This must be in a valid number format. No commas and only one decimal point.');
  if (!is_numeric($form_state['values']['weight']) && !preg_match($pattern, $form_state['values']['weight'])) {
    form_set_error('weight', $price_error);
  }
}