HTML5 Number Input - Always show 2 decimal places

后端 未结 15 2129
太阳男子
太阳男子 2020-11-28 05:43

Is there\'s any way to format an input[type=\'number\'] value to always show 2 decimal places?

Example: I want to see 0.00 instead of

15条回答
  •  情歌与酒
    2020-11-28 06:45

    Based on this answer from @Guilherme Ferreira you can trigger the parseFloat method every time the field changes. Therefore the value always shows two decimal places, even if a user changes the value by manual typing a number.

    
    
    
    

提交回复
热议问题