一:验证是否包含某个
是否包含一个数字
function test(){ var regx = /\d+/; alert(regx.test("sd3f2wf")); }
是否包含一个!
function test() { var regx = /!+/;; alert(regx.test("sd3f2wf")); }是否包含一个!或者@或者#
var patrn = /!+/ function test() { var regx = /[!+#+@@+]/; alert(regx.test("sd3f2wf")); }
二:验证是否是数字
function isDigit(s) { var patrn = /^[0-9]{1,20}$/; if (!patrn.exec(s)) return false return true }