如何使type =“number”只有正数 [英] How to make type="number" to positive numbers only
本文介绍了如何使type =“number”只有正数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我有以下代码:
<input type="number" />
出现这种情况
在右边允许数字变成负数。如何防止这种情况发生?
The little selector things on the right allow the number to go into negative. How do I prevent that?
我对使用 type =number
存在怀疑,它会导致更多问题比它解决的问题要多,所以我要去理智地检查它,所以我应该回到使用 type =text
?
I am having doubts about using type="number"
, it is causing more problems than it is solving, I am going to sanity check it anyways, so should I just go back to using type="text"
?
推荐答案
添加 a min
属性
<input type="number" min="0">
这篇关于如何使type =“number”只有正数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文