The new validation for decimal numbers does not work with browser chrome if a coma is used as decimal separator. (german number format)
If I put in the value "10,50" the browser chrome sends "10.5" in the post data and the validation in webform_number_format_match fails.
(I think it is because (only) chrome always converts the value of input fields with type "number" to a technical float value, like it is to be specified for this type of new HTML5 element.)

Comments

quicksketch’s picture

Title: problems with decimal numbers in chrome » Decimal numbers with comma as placeholder fail validation in Chrome
Status: Needs work » Active

If I put in the value "10,50" the browser chrome sends "10.5" in the post data and the validation in webform_number_format_match fails.

Whoa, I was not aware of that. HTML5 field elements are definitely still in the category of "very inconsistent" between browsers. Thanks for the report, I'll take a look at this when I get the chance. We've got several other issues with the number component as well, so it'll be good to fix these all before the next release.

quicksketch’s picture

I can't find any information on how to prevent Chrome from having this behavior. It seems to me that it's not possible to prevent it from doing this conversion. This unfortunately means that it's impossible for us to know the format that will be coming into the server. On Firefox, it'd be a comma (like you input originally), but on Chrome it'd be a decimal. This make validation very tough.

Potentially, we might avoid the use of the "number" HTML5 element until browser support is more consistent. The main reason we use it right now is to provide contextual keyboards for touch devices, but it seems there are alternatives for that, per http://danielfriesen.name/blog/2013/09/19/input-type-number-and-ios-nume...

Unfortunately I haven't been able to find a way to bring up a numeric keyboard that would allow commas and period characters as well. In iOS, you just get the integers when using the approaches described there.

So, at this point, not a lot of solutions. We'd need to give up iOS-friendly keyboards in order to solve this problem (which is probably worth it in my mind).

danchadwick’s picture

Version: 7.x-4.0-beta3 » 7.x-4.x-dev
danchadwick’s picture

Status: Active » Fixed

Fixed by virtue of fixing related issue #2290029: Thousands separator creates invalid value for HTML5 Number input by no longer using HTML5 form elements.

This fixes both 7.x-4.x and 8.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.