element_validate_number

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 element_validate_number($element, &$form_state)

Helper form element validator: number.

Related topics

Code

includes/form.inc, line 4055

<?php
function element_validate_number($element, &$form_state) {
  $value = $element['#value'];
  if ($value != '' && !is_numeric($value)) {
    form_error($element, t('%name must be a number.', array('%name' => $element['#title'])));
  }
}
?>