jQuery&validate验证:同名用户和字符限制。
工作中用到的,记录下来。新手一个,各位若有兴趣,可以留言讨论。
?
?
第一个:输入欲注册的用户名,即时验证该用户名是否存在。
?
一、JSP:
?
?
二、JS:
?二、JS:
$(function(){jQuery.validator.addMethod("regex",function(value, element, params) {var exp = new RegExp(params);return exp.test(value);}, "格式错误");$("#entpreg_stepfive").validate({rules:{'etp.userCode':{regex: "^\\w+$"}},messages:{'etp.userCode':{regex: "数字、字母或下划线"}}});});?
OVER!