zoukankan      html  css  js  c++  java
  • jquery validate 中highlight和unhighlight使用

    $(document).ready(function () {
                $('span.required').find('input').addClass('required');
    
                $('#form1').validate({
                    rules: {
                        txbCnfEmail: {
                            required: true,
                            email: true,
                            equalTo: "#txbEmail"
                        }
                    },
                    messages: {
                        txbFirstname: "Please enter your First Name",
                        txbLastname: "Please enter your Last Name",
                        txbAddress1: "Please enter your Mailing Address 1",
                        txbSuburb: "Please enter your Suburb",
                        ddlCountry: "Please select your country",
                        txbPostcode: {
                            required: "Please enter your Postcode",
                            number: "Please enter a valid Postcode"
                        },
                        ddlGender: "Please select your Gender",
                        ddlAge: "Please select your Age",
                        ddlHearFrom: "Please select",
                        txbEmail: {
                            required: "Please enter your Email Address",
                            email: "Please enter a valid Email Address"
                        },
                        txbCnfEmail: {
                            required: "Please enter a valid Confirm Email Address",
                            email: "Please enter a valid Confirm Email Address",
                            equalTo: "Confirm email address doesn't match the email address"
                        }
                    },
                    errorLabelContainer: "#error", 
                    highlight: function (element, errorClass) {
                        $(element).addClass(errorClass);
                        $("#error").find("label[for=" + element.id + "]")
                        .addClass(errorClass);
                        $(element).prev('label').addClass('error2');
                    },
                    unhighlight: function (element, errorClass) {
                        $(element).removeClass(errorClass);
                        $("#error").find("label[for=" + element.id + "]")
                        .removeClass(errorClass).css("display", "none");
                        $(element).prev('label').removeClass('error2');
                    }
                });
            });
  • 相关阅读:
    原创 爱因斯坦迷题及推导过程
    惊闻姑姑家女婿去世,哀叹生命之脆弱,死亡如此接近
    京东自营预售逻辑
    自营SKU绑定逻辑
    自营结算解释&对账逻辑
    CPS逻辑
    京东搜索结果数据异常
    C++静态库中使用_declspec(dllexport) 不能导出函数的问题
    HTTP+SVN访问速度慢的问题
    Python log
  • 原文地址:https://www.cnblogs.com/booth/p/2541792.html
Copyright © 2011-2022 走看看