You are here

function _field_hidden_check_numeric in Field Hidden 7

Checks that arg $str only consists of digits, and if decimal optionally a single dot.

Also allows leading hyphen (negative number).

Parameters

number|string $str:

boolean $decimal:

Return value

boolean

1 call to _field_hidden_check_numeric()
field_hidden_field_validate in ./field_hidden.module
Validation of field items upon form submission.

File

./field_hidden.module, line 534
Drupal Field Hidden module

Code

function _field_hidden_check_numeric($str, $decimal = FALSE) {
  return !$decimal ? preg_match('/^\\-?\\d+$/', $str) : preg_match('/^\\-?\\d+\\.?\\d*$/', $str);
}