jquery外掛程式validate裡面的remote參數用法

來源:互聯網
上載者:User

標籤:remote jquery valiadte

validate驗證在進行非同步資料庫查詢驗證的過程中用到了remote這個參數

 

remote裡面有url,dataType,data,type等等這幾個參數,當data不寫的時候預設是當前被驗證的欄位的值。傳值到php檔案中,在php檔案中處理的時候,傳回值為 “true”或者"false",傳回值需要加引號。

以下為一個測試案例:

js的寫法

  var option = {  rules:{   BaleNo:{    required:true,    remote:{     url:checkBaleNoUrl,     type:‘post‘,     dataType:‘json‘,    }   },   ExpressNoList:{    required:true   },  },  messages:{   BaleNo:{    required:‘托盤號不可為空‘,    remote:‘托盤號已經存在‘,   },   ExpressNoList:{    required:"運單號不可為空"       },  } };

php中方法的寫法:

 public function ajaxCheckTrayNo(){  if($_REQUEST[‘BaleNo‘]!=‘‘){   $model =  M("OrderTray");   $map[‘tray_no‘] = $_REQUEST[‘BaleNo‘];   $number = $model -> where($map) -> count();   if($number>0){    echo "false";   }else{    echo "true";   }     }else{   echo "false";  } }

本文出自 “芭菲雨的部落格” 部落格,請務必保留此出處http://bafeiyu.blog.51cto.com/5401101/1599317

jquery外掛程式validate裡面的remote參數用法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.