有趣的 验证JS只能输入正整数

2023-02-17,,,,

<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>

  

有趣验证JS只能输入正整数的相关教程结束。

《有趣的 验证JS只能输入正整数.doc》

下载本文的Word格式文档,以方便收藏与打印。