$("#qydm").formValidator({onshow:"请输入用户名",onfocus:"用户名至少1个字符,最多8个字符",oncorrect:"该用户名可以注册"}).inputValidator({min:1,max:8,onerror:"你输入的用户名非法,请确认"}).regexValidator({regexp:"username",datatype:"enum",onerror:"用户名格式不正确"})
.ajaxValidator({
type : "get",
url : "check.jsp",
//data: "user="+escape($('#qydm').val()),
cache :false,
datatype : "json",
success : function(data){
alert(data);
if( escape(data)=="1" )
{
//alert(document.getElementById('qydm').value);
return true;
}
else
{
alert(data);
return false;
}
},
buttons: $("#button"),
error: function(){alert("服务器没有返回数据,可能服务器忙,请重试");},
onerror : "该用户名不可用,请更换用户名",
onwait : "正在对用户名进行合法性校验,请稍候..."
});
动态验证用户的时候一定要注意一点 就是你在传值的时候 这 "#qydm" 是标记 传值的参数
jsp 是这样接受的
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="com.zgzhaogong.other.Check" %>
<%
String user=request.getParameter("qydm");//注意这面 和上面的 "#qydm"
if("".equals(user)){
out.println("非法操作");
}else{
System.out.println(user+"<------------------");
Check c=new Check();
out.println(c.check(user));
}
%>