1.
校验开头不能有空格:
jQuery.validator.addMethod("firstNotHasBlank", function(value, element) {
var fBlank =/^\S+/;
return this.optional(element) || (fBlank.test(value));
}, "开头不能有空格");
2. 校验结尾不能有空格:
jQuery.validator.addMethod("lastNotHasBlank", function(value, element) {
var lBlank =/\S+$/;
return this.optional(element) || (lBlank.test(value));
}, "结尾不能有空格");
3. 校验不能包含空格:
jQuery.validator.addMethod("notHasBlank", function(value, element) {
var pwdblank = /^\S*$/;
return this.optional(element) ||(pwdblank.test(value));
}, "不可包含空格");
jQuery.validator.addMethod("firstNotHasBlank", function(value, element) {
var fBlank =/^\S+/;
return this.optional(element) || (fBlank.test(value));
}, "开头不能有空格");
2. 校验结尾不能有空格:
jQuery.validator.addMethod("lastNotHasBlank", function(value, element) {
var lBlank =/\S+$/;
return this.optional(element) || (lBlank.test(value));
}, "结尾不能有空格");
3. 校验不能包含空格:
jQuery.validator.addMethod("notHasBlank", function(value, element) {
var pwdblank = /^\S*$/;
return this.optional(element) ||(pwdblank.test(value));
}, "不可包含空格");