You are here

function bat_options_element_value_validate in Booking and Availability Management Tools for Drupal 7

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

1 string reference to 'bat_options_element_value_validate'
bat_options_field_widget_form in modules/bat_options/bat_options.module
Implements hook_field_widget_form().

File

modules/bat_options/bat_options.module, line 324

Code

function bat_options_element_value_validate($element, &$form_state) {
  $value = $element['#value'];
  if ($value == '') {
    form_set_value($element, 0, $form_state);
  }
  elseif (!is_numeric($value) || $value <= 0) {
    form_error($element, t('%name must be a positive number.', array(
      '%name' => $element['#title'],
    )));
  }
}