I have a form with a number of numeric value fields. They all use a select box to display values that range from -20 to 20 using the field editor to set the range. For 0 or positive numbers, the form works as expected. When you submit a selection that is -10 as an example, the site returns Duke vs. Vac field value must format numbers as "12,346".

Before I dig too far into code, was wondering if I am missing something that would allow negative numbers to be submitted via select box. I tried altering it to an input field and it still rejected the negative number with the same error.

Wondering if I am missing something in the field config to permit negative numbers.

Thanks.

Comments

mepadre’s picture

Title: Numeric value in submit will not accept negative numbers » Numeric value in select will not accept negative numbers upon validation
mepadre’s picture

It seems that on my server, the following is returning -10 as an invalid entry.

function webform_number_format_match($value, $point, $separator) {
  return preg_match('/^([1-9](?:\d{0,2})(?:' . ($separator ? (preg_quote($separator, '/') . '?') : '') . '\d{3})*(?:' . preg_quote($point, '/') . '\d*[0-9])?|0?' . preg_quote($point, '/') . '\d*[1-9]|0)$/', $value);
}

Oddly, another server I have running the same webform version allows those entries so I gather it is something to do with my PHP version? The failing server is running:

Apache version 2.2.26
PHP version 5.4.25

Is it possible that this function is returning a different response depending on PHP version?

danchadwick’s picture

Status: Active » Closed (duplicate)

Negative numbers are accepted using the latest dev (post 4.0-beta3). Update to the latest dev or 4.0-beta4 (when released).
#2198007: Negative numbers always fail validation

There are other issues with numeric validation (e.g. 0.00 not being accepted) that are currently open.

mepadre’s picture

Sorry... it appears that when I searched it was only set to 'open' issues so I did not get the 'closed' issue. Much appreciated and apologies for the duplication.