溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

jqueryFormvalidator Ajax修改數(shù)據(jù)驗(yàn)證是否存在

發(fā)布時(shí)間:2020-05-29 03:23:01 來源:網(wǎng)絡(luò) 閱讀:872 作者:kafeihouye 欄目:web開發(fā)

 

  1. var accErrorMsg = "請(qǐng)輸入客戶分類名稱"
  2. //表單數(shù)據(jù)驗(yàn)證 
  3. $(function(){ 
  4.                 //$.formValidator.initConfig({formid:"myform",autotip:true});    
  5.         $.formValidator.initConfig({ 
  6.                     formid:"myform", 
  7.                     autotip:true 
  8.                 }); 
  9.                  
  10.                 $("#name").formValidator({ 
  11.                 onshow:"請(qǐng)輸入客戶分類名稱", 
  12.                 onfocus:"2至20個(gè)字符", 
  13.                 oncorrect:"輸入正確"}).functionValidator({ 
  14.                                         fun: function(){ 
  15.                                             var roleName = $("#name").val(); 
  16.                                             if(trim(roleName)=="") 
  17.                                             { 
  18.                                                  accErrorMsg = "請(qǐng)輸入客戶分類名稱"
  19.                                                  return accErrorMsg; 
  20.                                             }else if(trim(roleName).length==1 ||trim(roleName).length>20){ 
  21.                                                  accErrorMsg="2至20個(gè)字符"
  22.                                                  return accErrorMsg; 
  23.                                             } 
  24.                                             else 
  25.                                             {                                                
  26.                                                 return true; 
  27.                                             } 
  28.                                         } 
  29.                                     }).ajaxValidator({ 
  30.                                         type:"post", 
  31.                                         url: "${basePath}clientSortSTManage/clientSortST!isClientSortNameExist.action", 
  32.                                         datatype: "json", 
  33.                                         timeout: 3000,   
  34.                                         success: function(data) 
  35.                                         { 
  36.                                             //將老角色名與新角色名比較,如果一樣判為通過 
  37.                                             var oldName = $('#oldName').val(); 
  38.                                          
  39.                                             var rName = $('#name').val();    
  40.                                             if(oldName && oldName==rName) 
  41.                                             { 
  42.                                                 return true; 
  43.                                             }        
  44.                                          
  45.                                             //根據(jù)ajax返回結(jié)果判斷       
  46.                                             var correct = data.correct; 
  47.                                             if(correct) 
  48.                                             { 
  49.                                                 return true; 
  50.                                             } 
  51.                                             else 
  52.                                             { 
  53.                                                 return false; 
  54.                                             } 
  55.                                              
  56.                                              
  57.                                         },                               
  58.                                         error: function() 
  59.                                         { 
  60.                                             artalert("服務(wù)繁忙,請(qǐng)稍后再試!"); 
  61.                                         }, 
  62.                                         onerror : "客戶分類名稱已存在,請(qǐng)更換客戶分類名稱", 
  63.                                         onwait : "正在對(duì)客戶分類名稱進(jìn)行校驗(yàn),請(qǐng)稍候…" 
  64.                                     }).defaultPassed(); 
  65. }) 

 

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI