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

查看:25
本文介绍了类型=“数字"的 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/

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

推荐答案

截至目前 (30/08/2017),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天全站免登陆