- 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
「其他文章」