validate layer 提供友好驗證提示

來源:互聯網
上載者:User

標籤:amp   echo   undefined   ace   orm   分享   remove   dmi   ges   

草根一枚,網上搜尋很多關於validate驗證表單樣式的修改方法,但是都不理想,實在沒辦法,自己去研究,用了小半天的時間,效果算是可以把,吧代碼貼出來分享下,寫的不好勿怪!!!!直接代碼:

    $(function () {        //$.my_validate("#ajax_form");        //除去tips        function remove_layertips(obj) {            var layer_index = obj.attr(‘layer_index‘);            if (layer_index != "" && layer_index != undefined && layer_index != null) {                layer.close(layer_index);            }        }        $("#ajax_form").validate({            onkeyup: function (element) { $(element).valid(); },//切記這裡設定true 是會報錯的            focusCleanup: true,            success: function (element) {                var elem = $(element);                var itemId = elem[0].htmlFor;                var input_validate = $("#" + itemId);                remove_layertips(input_validate);            },            errorPlacement: function (error, element) {                var elem = $(element);                if (!error.is(‘:empty‘)) {                    var errorlist = elem.filter(‘:not(.valid)‘);                    errorlist.each(function () {                        remove_layertips($(this));                        index = layer.tips(error[0].innerText, $(this), {tips:[2,‘#acacac‘],  time: 0, tipsMore: true, zIndex: 2000, style: [‘background-color:#acacac;‘] });                        $(this).attr(‘layer_index‘, index);                    });                }            },        });    });

  html部分

 1    <form id="ajax_form" method="post" action="<?php echo site_url(‘admin/banner/add_banner‘)?>"> 2               3               <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic"> 4                   5                  <tr> 6                      <td width="100" align="right">權重</td> 7                      <td> 8                          <input type="text" name="weight" id="weight" size="40" class="inpMain " required digits="true" value="0" /> 9                      </td>10                  </tr>11                  <tr>12                      <td></td>13                      <td>14                          <input type="submit" class="btn" value="添加" />15                          <input name="button" class="btn not" type="button" value="取消">16                      </td>17                  </tr>18  19             </table>20          </form>

 

:

validate layer 提供友好驗證提示

聯繫我們

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