Jquery Validation :多個按鈕都需要做提交驗證的解決方案


$(document).ready(function() {
           
var _customer_query = {
                rules: {
                    txtCustEmail: {
                        required:
true,
                        email:
true
                    }
                },
//end rule
                messages: {
                    txtCustEmail: {
                        required:
"賬號不能為空",
                        email:
"請錄入正確格式的Email地址"
                    }
                }
//end message
            };
                 
           
var _customer_submit = {
                rules: {
txtCustAmount: {
                        required:
true
                    }
                },
//end rule
                messages: {
                    txtCustAmount: {
                        required:
"金額不能為空"
                    }
                }
//end message
            };

           
var validate_settings_query = jQuery.extend({}, _default, _customer_query);
           
var validate_settings_submit = jQuery.extend({}, _default, _customer_submit);
           
            $(
"#btnQuery").click(function() {
                $(
"form").validate(validate_settings_query);
            });

            $(
"#btnSubmit").click(function() {
                $(
"form").validate(validate_settings_submit);
            });
           
        });


 


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com