Bootstrap

【前端】input输入框只能输入大于等于0的正数

大于等于0的正数,允许小数

<input  type="number" step="1"  min="0" οnkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''">

 

大于0的正整数

<input type="text" placeholder="输入金额" style="width: 80px;"  value="" οnkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"/>

 

转载于:https://www.cnblogs.com/chinaifae/p/10400181.html

;