//校验密码是否含有空格 jQuery.validator.addMethod("notblank", function(value, element) { var pwdblank = /^\S*$/; return this.optional(element) ||(pwdblank.test(value)); }, "密码不可包含空格"); //用户名必须需包含数字和大小写字母中至少两种 jQuery.validator.addMethod("userrule", function(value, element) { var userblank = /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)[0-9A-Za-z]{5,10}$/; return this.optional(element) ||(userblank.test(value)); }, "需包含数字和大小写字母中至少两种字符的5-10位字符");