How to make type=“number” to positive numbers only

后端 未结 17 2393
既然无缘
既然无缘 2020-11-30 17:12

currently I have the following code


it comes out to something like this

17条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 18:03

    add this code in your input type;

    onkeypress="return (event.charCode == 8 || event.charCode == 0 || event.charCode == 13) ? null : event.charCode >= 48 && event.charCode <= 57"
    

    for example:

    
    

提交回复
热议问题