开发者

HTML5 number input step bug

I am trying to use the new HTML5 number input for users to input a price. I want the step to be "0.01". This should be fairly simple, and my code looks like this:

<input type="number" step="0.01" />

Well if you click on the arrows a bit, you'll get numbers like 1.1400000000000001 or numbers like 1.1 which both don't make sense for dollars.

Does anyone know of a way to make the number field actually step by 0.01, and to have a consistent number of significant figures? Or if anyone has a more elegant so开发者_如何学运维lution for allowing users to input prices, I would love to hear it.

Thanks


Well, first of all expecting Html 5 stuff to work as expected so early in the game and designing applications around that is probably not such a good idea.

As for a solution, yes just to JavaScript to increment and provide the user to up/down arrows or whatever and the click event could simple increment/decrement the value by the step value you desire.


this is the expected javascript behavior, you can take a look at this answer

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜