
减掉的工作,只要你做减法运算就行了,用你的数减掉文本框里的数.
也还有其它的办法,就是把文本框的数字转换成数值,然后取绝对值即可.
<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>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)