1

I'm trying to get decimals to work in a input field of type number. To implement this I'm trying to modify the step attribute.

 <input name="aNumberInput" type="number" min="10000" max="400000" step=".001"  id="with-step"/>

I've found the implementation in IE10 doesn't work, the validation is completely sporadic. For example, use the following jsFiddle and try inputting 11111.232, then try 11111.222. For some reason the .232 validates but the .222 does not.

http://jsfiddle.net/4PQn9/

4

4 回答 4

1

当测试这个..这是否发生在

浏览器模式:IE10

文档模式:标准

???

IE10确实支持输入数字类型,但不显示递增/递减按钮。

http://msdn.microsoft.com/en-us/library/ie/hh773064%28v=vs.85%29.aspx

检查浏览器支持:

http://caniuse.com/#feat=input-number

IE 中支持的输入类型列表:

http://msdn.microsoft.com/en-us/library/ie/ms534700%28v=vs.85%29.aspx

更新

看起来这里也有人问过这个问题:

HTML数字输入删除小数点?

在 HTML5 数字输入中强制使用小数点而不是逗号(客户端)

http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/

于 2013-11-14T20:19:59.647 回答
1

IE10 不完全支持输入类型编号(IE9 及更低版本不支持),因为它在 FF 或 Chrome 中支持。

在 microsoft 网站 http://msdn.microsoft.com/en-us/library/ie/hh773064%28v=vs.85%29.aspx查看此文档

更新:-跨浏览器支持输入类型编号 http://caniuse.com/input-number

于 2013-11-14T19:12:09.603 回答
0

要允许 IE10 中的数字输入类型使用小数,您可以使用 step 的“any”值,这将改变它的默认值“1”。 http://dev.w3.org/html5/markup/input.number.html

<input name="aNumberInput" type="number" min="10000" max="400000" step="any"  id="with-step"/>

http://jsfiddle.net/C2HU2/

我的目标是保持最小值-最大值、数字验证,并允许将十进制/浮点值提交到表单。这为我实现了这一点。镀铬的步进器以 1 递增,这也足够了。

于 2013-11-14T20:51:52.010 回答
0

我也有类似的问题。但是,IE 不支持 input type="number" 但您可以使用 jQueryUI Spinner 小部件。它使用起来非常简单,并且有许多对开发人员友好的 API。

jQuery-UI Spinner 演示: https ://jqueryui.com/spinner/

jQuery-UI Spinner API https://api.jqueryui.com/spinner/#event-change

于 2019-11-22T08:28:45.237 回答