[whatwg] Decimal comma in numeric input

Jukka K. Korpela jkorpela at cs.tut.fi
Thu Apr 14 02:05:08 PDT 2011

I was surprised at seeing that the Finnish-language version of Google Chrome 
11 beta accepts a number with a comma, such as "4,2", in <input 
type="number">. It silently converts the comma to a full stop, "4.2".

This looked like a useful feature at first sight, as decimal comma is 
standard in Finnish as in most human languages. But this seems to violate 
the rules, since <input type="number"> is defined as allowing a "valid 
floating point number" (the definition of which clearly allows FULL STOP as 
the only decimal separator) only and, moreover, there is prescribed error 
processing: an error shall be returned, and the value sanitization algorithm 
shall set the value to the empty string; ref.:

So the Google Chrome implementation is in error here, right?

On the other hand, would it be useful to _allow_ localization so that a 
browser _may_ interpret a comma as a decimal separator? Perhaps assuming the 
localization settings of the browser or the underlying system specify comma 
as decimals separator, or perhaps independently of that.

Google Chrome seems to take the localization so far that if I specify 
value="4.2", it gets displayed as "4,2", and if I type "5.5" in the field, 
it gets automatically converted to "5,5" in the visible rendering - though 
in DOM and in the submitted form data, it's "5.5".

Things get risky, because if the user then enters "1.500" (which corresponds 
to the old way of writing one thousand five hundred in digits in Finnish, a 
notation still used to some extent and still official in some other 
languages) in <input type="number"> field, it gets accepted and sent as 
"1.500" (one and a half), if the value restrictions allow it - though the 
visual rendering is automatically changed to "1,5".

I guess the big question is: Should localization issues be concerned in the 
specification of <input type="number">? If not, the usefulness of the 
construct is limited, since in many contexts it is unacceptable to require 
that users input and see numbers in a format that does not correspond to 
conventions that are normal for their language and culture.

Yucca, http://www.cs.tut.fi/~jkorpela/ 

More information about the whatwg mailing list