Input type=number : Firefox 将浮点数转换为整数,当小数点后有 3 位数字时

Input type=number : Firefox converts floating point number to integer when there are 3 digit after a point

在 Firefox 34 上,我在 <input type="number">.

上出现奇怪的行为

当键入类似 11.001 的内容时(请注意这一点),它会转换为 110001

只有点后有3位数字时才会出现这种情况。

有没有办法阻止这种行为?

顺便说一句:我注意到法语 Windows 7.

您的浏览器使用的是法语语言环境,法语使用逗号作为小数点分隔符,句点代表千位

来自Mozilla documentation

Localization

The allowed inputs for certain types depend on the locale. In some locales, 1,000.00 is a valid number, while in other locales the valid way to enter this number is 1.000,00.

Firefox uses the following heuristics to determine the locale to validate the user's input (at least for type="number"):

  • Try the language specified by a 'lang'/'xml:lang' attribute on the element or any of its parents;

  • Try the language specified by any Content-Language HTTP header or

  • If none specified, use the browser's locale.

如果您想更改此行为,请使用:

<input lang="en" type="number">