继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

jqueryFormvalidator Ajax修改数据验证是否存在

Qyou
关注TA
已关注
手记 255
粉丝 52
获赞 361

 

var accErrorMsg = "请输入客户分类名称"; //表单数据验证 $(function(){                 //$.formValidator.initConfig({formid:"myform",autotip:true});            $.formValidator.initConfig({                     formid:"myform",                     autotip:true                 });                                  $("#name").formValidator({                 onshow:"请输入客户分类名称",                 onfocus:"2至20个字符",                 oncorrect:"输入正确"}).functionValidator({                                         fun: function(){                                             var roleName = $("#name").val();                                             if(trim(roleName)=="")                                             {                                                  accErrorMsg = "请输入客户分类名称";                                                  return accErrorMsg;                                             }else if(trim(roleName).length==1 ||trim(roleName).length>20){                                                  accErrorMsg="2至20个字符";                                                  return accErrorMsg;                                             }                                             else                                             {                                                                                                return true;                                             }                                         }                                     }).ajaxValidator({                                         type:"post",                                         url: "${basePath}clientSortSTManage/clientSortST!isClientSortNameExist.action",                                         datatype: "json",                                         timeout: 3000,                                           success: function(data)                                         {                                             //将老角色名与新角色名比较,如果一样判为通过                                             var oldName = $('#oldName').val();                                                                                      var rName = $('#name').val();                                                if(oldName && oldName==rName)                                             {                                                 return true;                                             }                                                                                             //根据ajax返回结果判断                                                   var correct = data.correct;                                             if(correct)                                             {                                                 return true;                                             }                                             else                                             {                                                 return false;                                             }                                                                                                                                   },                                                                       error: function()                                         {                                             artalert("服务繁忙,请稍后再试!");                                         },                                         onerror : "客户分类名称已存在,请更换客户分类名称",                                         onwait : "正在对客户分类名称进行校验,请稍候…"                                     }).defaultPassed(); })

 

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP