You are here

function _auto_username_validate_numeric_element in Automatic User Names 7

Validate a form element that should have an numeric value.

1 string reference to '_auto_username_validate_numeric_element'
auto_username_settings_form in ./auto_username.admin.inc
@file Form builder; displays the auto_username settings form.

File

./auto_username.admin.inc, line 168
Form builder; displays the auto_username settings form.

Code

function _auto_username_validate_numeric_element($element, &$form_state) {
  $value = $element['#value'];
  if (!is_numeric($value)) {
    form_error($element, t('The field %name is not a valid number.', array(
      '%name' => $element['#title'],
    )));
  }
  elseif (isset($element['#max_value']) && $value > $element['#max_value']) {
    form_error($element, t('The field %name cannot be greater than @max.', array(
      '%name' => $element['#title'],
      '@max' => $element['#max_value'],
    )));
  }
  elseif (isset($element['#min_value']) && $value < $element['#min_value']) {
    form_error($element, t('The field %name cannot be less than @min.', array(
      '%name' => $element['#title'],
      '@min' => $element['#min_value'],
    )));
  }
}