jquery自訂控制項驗證篇,jquery自訂控制項

來源:互聯網
上載者:User

jquery自訂控制項驗證篇,jquery自訂控制項

QQ:1187362408 歡迎技術交流和學習

jquery自訂控制項驗證篇(自訂控制項):

TODO:

1,關於普通的jquery.validater.js驗證,略

2,自訂控制項驗證:

<span style="color:#000000;">function CheckInput() {    var result = $("#form1").validate({        rules: {            uc_btnSelectArea1$txtAreaName: {                requiredgPID: true            },            procheckbox: {//省級角色                requiredproCheck: true            },            citycheckbox: {//市級角色                requiredcityCheck: true            },            councheckbox: {//縣角色                requiredcounCheck: true            },            towncheckbox: {//鄉鎮角色                requiredtownCheck: true            },            villcheckbox: {//村級角色                requiredvillCheck: true            },            girdcheckbox: {//網格角色                requiredgirdCheck: true            }        }    });    return result.form();};//[省]使用者角色必選jQuery.validator.addMethod("requiredproCheck", function (value, element) {    var chkvalue = false;    var areacode = $("#uc_btnSelectArea1_hidAreaCode").val();    var areaLevel = GetJbByCode(areacode);//勾選的當前地區層級(0:省級1:市級2:縣級3:鄉鎮級4:村級)    if (areaLevel < 1) {        $("[name='procheckbox'][checked]").each(function () {            chkvalue = true;        });    } else {        chkvalue = true;    }    return chkvalue;}, "*至少選擇一個省級使用者角色")//[市]使用者角色必選jQuery.validator.addMethod("requiredcityCheck", function (value, element) {    var chkvalue = false;    var areacode = $("#uc_btnSelectArea1_hidAreaCode").val();    var areaLevel = GetJbByCode(areacode);//勾選的當前地區層級(0:省級1:市級2:縣級3:鄉鎮級4:村級)    if (areaLevel < 2) {        $("[name='citycheckbox'][checked]").each(function () {            chkvalue = true;        });    } else {        chkvalue = true;    }    return chkvalue;}, "*至少選擇一個市級使用者角色")//[縣]使用者角色必選jQuery.validator.addMethod("requiredcounCheck", function (value, element) {    var chkvalue = false;    var areacode = $("#uc_btnSelectArea1_hidAreaCode").val();    var areaLevel = GetJbByCode(areacode);//勾選的當前地區層級(0:省級1:市級2:縣級3:鄉鎮級4:村級)    if (areaLevel < 3) {        $("[name='councheckbox'][checked]").each(function () {            chkvalue = true;        });    } else {        chkvalue = true;    }    return chkvalue;}, "*至少選擇一個縣級使用者角色")//[鄉鎮]使用者角色必選jQuery.validator.addMethod("requiredtownCheck", function (value, element) {    var chkvalue = false;    var areacode = $("#uc_btnSelectArea1_hidAreaCode").val();    var areaLevel = GetJbByCode(areacode);//勾選的當前地區層級(0:省級1:市級2:縣級3:鄉鎮級4:村級)    if (areaLevel < 4) {        $("[name='towncheckbox'][checked]").each(function () {            chkvalue = true;        });    } else {        chkvalue = true;    }    return chkvalue;}, "*至少選擇一個鄉鎮級使用者角色")//[村]使用者角色必選jQuery.validator.addMethod("requiredvillCheck", function (value, element) {    var chkvalue = false;    var areacode = $("#uc_btnSelectArea1_hidAreaCode").val();    var areaLevel = GetJbByCode(areacode);//勾選的當前地區層級(0:省級1:市級2:縣級3:鄉鎮級4:村級)    if (areaLevel < 5) {        $("[name='villcheckbox'][checked]").each(function () {            chkvalue = true;        });    } else {        chkvalue = true;    }    return chkvalue;}, "*至少選擇一個村級使用者角色")//[網格]使用者角色必選jQuery.validator.addMethod("requiredgirdCheck", function (value, element) {    var chkvalue = false;    var areacode = $("#uc_btnSelectArea1_hidAreaCode").val();    var areaLevel = GetJbByCode(areacode);//勾選的當前地區層級(0:省級1:市級2:縣級3:鄉鎮級4:村級)    if (areaLevel < 6) {        $("[name='girdcheckbox'][checked]").each(function () {            chkvalue = true;        });    } else {        chkvalue = true;    }    return chkvalue;}, "*至少選擇一個網格使用者角色")jQuery.validator.addMethod("requiredgPID", function (value, element) {    return value != "";}, "*地區不可為空!");</span>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.