// 修改
$("#updForm").validate({
submitHandler:function(form){
new $.flavr({
content : '是否确认修改管理员?',
dialog : 'confirm',
onConfirm : function() {
$.ajax({
url : "/system/doAuthAdminUpd",
type : "post",
data : { "id" : $("#updAuthId").val(),
"name" : $("input[name=updName]").val(),
"account" : $("input[name=updAccount]").val(),
"roleIds" : $("select[name=updRoleIds]").val().toString() },
success : function(result) {
if (result.status == 200) {
$.tooltip(result.msg, true); // 显示提示
$('#updTable').modal('hide'); // 隐藏表单
myTable.ajax.url('/system/getAuthAdminList').load(); //重新加载
} else {
$.tooltip(result.msg, false);
}
}
});
}
});
},
debug:false,
rules:{
updName:{required:true,maxlength:10},
updAccount:{required:true,maxlength:20,isNumberAndLetter:true,
remote:{
url:"/system/checkAuthAdminAccount",
type:"get",
data:{
account:function(){
return $("input[name=updAccount]").val().trim();
}
}
}},
updRoleIds:{required:true}
},
messages:{
updName:{required:"请输入昵称",maxlength:$.validator.format("长度不能大于{0}个字符")},
updAccount:{required:"请输入帐号",maxlength:$.validator.format("长度不能大于{0}个字符"),remote:"管理员帐号已存在"},
updRoleIds:{required:"请选择角色"}
},
errorPlacement:function(error,element){
layer.tips(error.text(),element,{tips:1,time:2000,tipsMore:true});
}
});
})// 修改
$("#updForm").validate({
submitHandler:function(form){
new $.flavr({
content : '是否确认修改管理员?',
dialog : 'confirm',
onConfirm : function() {
$.ajax({
url : "/system/doAuthAdminUpd",
type : "post",
data : { "id" : $("#updAuthId").val(),
"name" : $("input[name=updName]").val(),
"account" : $("input[name=updAccount]").val(),
"roleIds" : $("select[name=updRoleIds]").val().toString() },
success : function(result) {
if (result.status == 200) {
$.tooltip(result.msg, true); // 显示提示
$('#updTable').modal('hide'); // 隐藏表单
myTable.ajax.url('/system/getAuthAdminList').load(); //重新加载
} else {
$.tooltip(result.msg, false);
}
}
});
}
});
},
debug:false,
rules:{
updName:{required:true,maxlength:10},
updAccount:{required:true,maxlength:20,isNumberAndLetter:true,
remote:{
url:"/system/checkAuthAdminAccount",
type:"get",
data:{
account:function(){
return $("input[name=updAccount]").val().trim();
}
}
}},
updRoleIds:{required:true}
},
messages:{
updName:{required:"请输入昵称",maxlength:$.validator.format("长度不能大于{0}个字符")},
updAccount:{required:"请输入帐号",maxlength:$.validator.format("长度不能大于{0}个字符"),remote:"管理员帐号已存在"},
updRoleIds:{required:"请选择角色"}
},
errorPlacement:function(error,element){
layer.tips(error.text(),element,{tips:1,time:2000,tipsMore:true});
}
});
})
引用的js:
<!-- jQuery -->
<script charset="utf-8" src="/js/jquery.min.js"></script>
<!-- jQuery Validate -->
<script charset="utf-8" src="/js/jquery.validate-1.13.1.min.js"></script>
<script charset="utf-8" src="/js/additional-methods.js"></script><!-- jQuery Validate -->
<script charset="utf-8" src="/js/jquery.validate-1.13.1.min.js"></script>
<script charset="utf-8" src="/js/additional-methods.js"></script>
<!-- Validate Alert -->
<script charset="utf-8" src="/js/livedemo.js"></script>
<script charset="utf-8" src="/js/flavr.min.js"></script>
效果类似于:(以上代码和以下效果不是同一个页面验证,但效果就是这种)