类型=“数字”的HTML5输入框在Chrome浏览器中不接受逗号 [英] HTML5 input box with type="number" does not accept comma in Chrome browser

查看:281
本文介绍了类型=“数字”的HTML5输入框在Chrome浏览器中不接受逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 type =number的HTML5输入框。关于一些文件,如果我也使用 lang =属性,应该可以用逗号(而不是句号)输入一个数字。它适用于Firefox,但不适用于Chrome(不接受逗号)。如何让Chrome在输入框中接受逗号?
我的问题是我们的德国用户希望他们可以输入逗号而不是那里的逗号。

I am using a HTML5 input box with type="number". Regarding to some documentations, it should be possible to enter a number with comma (not with period) if I also use the lang="" attribute. It is working in Firefox, but not in Chrome (does not accept a comma). How can I get Chrome to accept the comma in the input box. My problem is that our German users expect that they can enter a comma instead of a period there.

https://jsfiddle.net/byte2702/y3Lpfw7m/

https://jsfiddle.net/byte2702/y3Lpfw7m/

Please enter a number with comma: <br/>
<input id="num" type="number" step="any" lang="de" pattern="-?[0-9]+[\,.]*[0-9]+" /> 


推荐答案

截至目前(2017年8月30日), Antoine Thiry的答案似乎在Chrome中不再有效(我的版本是60.0.3112.113)。不幸的是,我没有任何其他建议,除了用javascript模拟type =number。

As of now (30/08/2017), Antoine Thiry's answer seems to be no longer valid in Chrome (my version is 60.0.3112.113). Unfortunately I don't have any other suggestion, other than simulating type="number" with javascript.

这篇关于类型=“数字”的HTML5输入框在Chrome浏览器中不接受逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆