JS只能输入正整数

来源:互联网 发布:高通骁龙835超频软件 编辑:程序博客网 时间:2024/05/22 03:52
<html><head><title>只能输入正整数</title></head><body>兑换数量:<input type="text" ID="txtNumber" Width="50px" onkeyup="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,'0')}else{this.value=this.value.replace(/\D/g,'')}" /><input type="button" ID="btn1" value=" 兑  换 " OnClick='return confirm("确定兑换?");' /></body></html>

 
原创粉丝点击