input 限制只能输入数字

input只能输入小数点保留2位的正数

<input type="text" placeholder="请输入" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" />

input只能输入正整数

<input type="text" placeholder="请输入" onkeyup="this.value=this.value.replace(/\D|^0/g,'')" onafterpaste="this.value=this.value.replace(/\D|^0/g,'')">

 

posted @ 2020-10-19 16:12  阳光下那抹高傲的轻笑  阅读(215)  评论(0编辑  收藏  举报