完整示例代码:
- <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
- <html>
- <head>
- <metahttp-equiv="Content-Type"content="text/html;charset=GB2312"/>
- <title>正则实现文本框只能输入正整数</title>
- </head>
- <body>
- <inputtype="text"onkeyup="this.value=this.value.replace(/\D/g,'')"onafterpaste="this.value=this.value.replace(/\D/g,'')"/>
- </body>
- </html>
核心代码:
- <inputtype="text"onkeyup="this.value=this.value.replace(/\D/g,'')"onafterpaste="this.value=this.value.replace(/\D/g,'')"/>








发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。