You are here

function rooms_element_validate_integer_positive_less_than_100 in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Form element validation handler for integer elements positive less than 100.

1 string reference to 'rooms_element_validate_integer_positive_less_than_100'
rooms_booking_children_discount in modules/rooms_booking/rooms_booking.module
Form callback for rooms_booking_children_discount form.

File

./rooms.module, line 1326
Provides basic underlying functionality and configuration options used by all Rooms modules

Code

function rooms_element_validate_integer_positive_less_than_100($element, &$form_state) {
  $value = $element['#value'];
  if ($value !== '' && (!is_numeric($value) || intval($value) != $value || $value < 0 || $value > 100)) {
    if ($value < 0) {
      form_error($element, t('%name must be greater than 0.', array(
        '%name' => $element['#title'],
      )));
    }
    elseif ($value > 100) {
      form_error($element, t('%name must be less than 100.', array(
        '%name' => $element['#title'],
      )));
    }
  }
}