日期:2014-05-16 浏览次数:20695 次
$("#us").formValidator( {
onShowText : "请输入用户名",
onShow : "请输入用户名",
onFocus : "用户名至少5个字符,最多10个字符",
onCorrect : "该用户名可以注册"
}).inputValidator( {
min : 5,
max : 10,
onError : "你输入的用户名非法,请确认"
}).regexValidator( {
regExp : "^([a-zA-Z])([a-zA-Z0-9_]){4,11}$",
onError : "只能是字母、数字、下划线的组合"
}).ajaxValidator({
dataType : "html",
async : true,
url : "user/checkUserName.action",
success : function(data){
if( data == "0" ) {return true;}else{
return "该用户名不可用,请更换用户名";}
},
buttons: $("#button"),
error: function(jqXHR, textStatus, errorThrown){alert("服务器没有返回数据,可能服务器忙,请重试"+errorThrown);},
onError : "该用户名不可用,请更换用户名",
onWait : "正在进行合法性校验,请稍候..."
});
public String checkUserName() {
try {
System.out.println("Ajax验证");
listAllUser = this.userService.findByNameT(user.getUsername());
if (!listAllUser.isEmpty()) {
System.out.println("重复的用户名");
return "1";
} else {
return "0";
}
} catch (Exception e) {
e.printStackTrace();
return INPUT;
}
}
<action name="checkUserName" class="userBean" method="checkUserName">
<result name="success">/web/modifySuccess1.jsp</result>
<result name="input">/web/modifyFailure1.jsp</result>
<result name="reseted">/web/reseted.jsp</result>
</action>
Ajax验证
Ajax验证
Hibernate:
select
orderuser0_.username as col_0_0_
from
orderSys.dbo.order_user orderuser0_
where
orderuser0_.username='a145s7'
success : function(data){
data=parseInt(data,10)//转为数字
&