zoukankan      html  css  js  c++  java
  • jquery Validation 插件

    官方文档地址:http://docs.jquery.com/Plugins/Validation

    官方下载地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation/

    $(document).ready(function () {
        jQuery.validator.addMethod('CheckCheckBoxList',
                function (value, element) {
                    var checkedLength = $("#" + chklMemberGuardianship + " input:checked").length;
                    if (checkedLength > 0)
                        return true;
                    if ($("#" + dropServiceCombo).val() != "-1")
                        return true;
                    else
                        return false;
                },
               Remp_PleaseChoose
            );

        $.validator.setDefaults({
            submitHandler: function (form) {
                if ($(formid).validate.cancelSubmit || $(formid).valid()) {
                    form.submit();
                }
            }
        });

        var formid = $("form").first();
        $(formid).validate({
            errorElement: "em",
            errorPlacement: function (error, element) {
                if (element.is(":radio"))
                    error.appendTo(element.parent().next().next());
                else if (element.is(":checkbox")) {
                    var checkship = $("#" + chklMemberGuardianship);
                    error.appendTo(checkship.parent());
                }
                else
                    error.appendTo(element.parent());
            }
        });

        //验证规则
        $("#" + txtMemberID).rules("add", { required: true, CheckHtml: true, CheckMemberIDIsExists: true, messages: { required: Remp_NotNull} });
        $("#" + txtIntervalPeriod).rules("add", { required: true, digits: true, min: 1, messages: { required: Remp_NotNull, digits: Remp_ValidIntPostiveErrorInfo, min: Remp_ValidIntPostiveErrorInfo} });
        $("#" + txtBeginDate).rules("add", { required: true, messages: { required: Remp_NotNull} });
        $("#" + txtMemberGroup).rules("add", { CheckHtml: true });
        $("#" + dropParentOrgID).rules("add", { CheckSelect: true });
        $("#" + dropServicePeriod).rules("add", { CheckSelect: true });
        $("#" + chklMemberGuardianship + "_1").rules("add", { CheckCheckBoxList: true });
        $("#" + txtMemberGroup).rules("add", { CheckMemberGroup: true });
        $("#" + edate).rules("add", { CheckEndDate: true });
    });

  • 相关阅读:
    段错误诊断!
    kissthank
    c实现面向对象编程(3)
    字符串转换成数字以及注意事项
    【Java并发编程实战】-----“J.U.C”:CLH队列锁
    c编程:僵尸吃大脑
    展示C代码覆盖率的gcovr工具简单介绍及相关命令使用演示样例
    最优化学习笔记(三)最速下降法
    maven学习
    ASP.NET MVC 入门4、Controller与Action
  • 原文地址:https://www.cnblogs.com/50614090/p/2216535.html
Copyright © 2011-2022 走看看