<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <Meta http-equiv="Content-Type" content="text/html; charset=GB2312" /> <title>正则实现文本框只能输入正整数</title> </head> <body> <input type="text" onKeyUp="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" /> </body> </html>原文链接:https://www.f2er.com/regex/362004.html