jquery的validate的用法

來源:互聯網
上載者:User

標籤:find   事件   app   ida   erro   asc   1.4   set   tde   

//引入js檔案

//jquery 檔案

<script src="__PUBLIC__/static/wap/js/jquery.min.js?v=2.1.4">
</script>

//jquery 的表單提交外掛程式
<script src="__PUBLIC__/static/wap/js/jquery.form.js">
</script>

//驗證js類
<script src="__PUBLIC__/static/wap/plugins/validate/jquery.validate.min.js">
</script>

//.新添加的驗證規則
<script src="__PUBLIC__/static/wap/plugins/validate/additional-methods.js">
</script>

//驗證提示訊息
<script src="__PUBLIC__/static/wap/plugins/validate/messages_zh.min.js">
</script>




//定義驗證預設樣式jQuery.validator.setDefaults({highlight: function(e) {//刪除表單元素上的錯誤提示樣式 $(e).removeClass("err-r"); }, errorElement: ‘div‘, errorClass: "er-r", errorPlacement: function(error, element) { error.appendTo(element.parent().find(‘.err‘)); }});//設定後台登入驗證$().ready(function() { var e = "<i class=‘fa fa-times-circle‘></i> "; $("#login").validate({ rules: { mobile: { required: !0, isMobile: true }, password: { required: !0 } }, messages: { mobile: { required: e + "手機號必須!", isMobile: e + "格式錯誤!" }, password: { required: e + "密碼必須!"} }, submitHandler: function(form) { var m = $("#phone-1").val(); var p = $("#pwd-2").val();$("#login").ajaxSubmit({ type: ‘post‘, // 提交方式 get/post url: "{:url(‘wap/Login/login‘)}", // 需要提交的 url data: { ‘mobile‘: m, ‘password‘:p }, success: function(data) { // data 儲存提交後返回的資料,一般為 json 資料 // 處理返回data show_msg(data); } }); return false; // 阻止表單自動認可事件 } })});

  

jquery的validate的用法

聯繫我們

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