• 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');
                    }
                });
            });
  • 相关阅读:
    【React】哪些数据应该放到state中?
    React组件生命周期及组件之间的通信
    【Flex布局教程】语法篇
    jQuery动态创建二级下拉菜单
    Web前端工程师成长之路——知识汇总
    Jpcap使用指南
    安装/重装tomcat(组图)
    贪吃蛇小游戏(含详细思路及源代码)
    servlet中如何操作数据库
    svn的使用方法
  • 原文地址:https://www.cnblogs.com/booth/p/2541792.html
Copyright © 2020-2023  润新知