- Allow 2 decimal places in "/>

允许保留 2 位小数 - Allow 2 decimal places in

语言: CN / TW / HK

问题:

I have a <input type="number"> and I want to restrict the input of the users to purely numbers or numbers with decimals up to 2 decimal places.我有一个<input type="number">并且我想将用户的输入限制为纯数字或小数点后最多 2 位小数的数字。

Basically, I am asking for a price input.基本上,我要求输入价格。

I wanted to avoid doing regex.我想避免做正则表达式。 Is there a way to do it?有没有办法做到这一点?

<input type="number" required name="price" min="0" value="0" step="any">

解决方案:

参考一: http://stackoom.com/question/2Itw3
参考二: Allow 2 decimal places in
「其他文章」