When jqGrid is added determines the start date and end date of instance resolution

  • 2020-03-26 23:48:56
  • OfStack


$("#btnAddSaveTestSubject").click(function () {
        //Add validation, save
        jQuery.validator.addMethod("admissionBatch", function (value, element) {
            return this.optional(element) || value != 0;
        }, " Please select the enrollment batch ");
        jQuery.validator.addMethod("educationLevel", function (value, element) {
            return this.optional(element) || value != 0;
        }, " Please select educational level ");
        jQuery.validator.addMethod("professionalProperty", function (value, element) {
            return this.optional(element) || value != 0;
        }, " Please choose professional nature ");
        $("#AddEntranceTestSubjectFrom").validate({
            event: "blur",
            debug: true,
            ignore: ":hidden",
            errorElement: "div",
            wrapper: "div",
            errorPlacement: function (error, element) {
                error.addClass('message');
                error.appendTo(element.parent());
            },
            rules: {
                "etsadd_admissionBatch": {
                    required: true,
                    admissionBatch: true
                },
                "etsadd_educationLevel": {
                    required: true,
                    educationLevel: true
                },
                "etsadd_professionalProperty": {
                    required: true,
                    professionalProperty: true
                }
            },
            messages: {
                "etsadd_admissionBatch": {
                    required: " Please select the enrollment batch ",
                    admissionBatch: " Please select the enrollment batch "
                },
                "etsadd_educationLevel": {
                    required: " Please select the type of education ",
                    educationLevel: " Please select the type of education "
                },
                "etsadd_professionalProperty": {
                    required: " Please choose professional nature ",
                    professionalProperty: " Please choose professional nature "
                }
            },
            submitHandler: function (form) {
                var idArray = jQuery("#testSubjectGrid").jqGrid('getGridParam', 'selarrrow'); //Gets the line & NBSP; selected by the test subject;
                if (idArray == null || idArray == "") {
                    jAlert(" Please select a test subject !", " Prompt information ");
                    return;
                }
                for (var i = 0; i < idArray.length; i++) {
                    if ($("#exam_begintime_" + idArray[i]).val() == "") {
                        jAlert(" The test subjects " + jQuery("#testSubjectGrid").jqGrid("getCell", idArray[i], "display_content") + " The start time of !", " Prompt information ");
                        return;
                    }
                    if ($("#exam_endtime_" + idArray[i]).val() == "") {
                        jAlert(" The test subjects " + jQuery("#testSubjectGrid").jqGrid("getCell", idArray[i], "display_content") + " The end time of !", " Prompt information ");
                        return;
                    }
                    var reg_ymd = /^([/d]{4})-([/d]{1,2})-([/d]{1,2})$/; //Verify the regularity of the date
                    begindata = $("#exam_begintime_" + idArray[i]).val();
                    enddata = $("#exam_endtime_" + idArray[i]).val();
                    var arr_dt1, arr_dt2;
                    arr_dt1 = begindata.match(reg_ymd);
                    arr_dt2 = enddata.match(reg_ymd);
                    begindata = new Date(arr_dt1[1] + "/" + arr_dt1[2] + "/" + arr_dt1[3]);
                    enddata = new Date(arr_dt2[1] + "/" + arr_dt2[2] + "/" + arr_dt2[3]);
                    if (begindata > enddata) {
                        jAlert(" The test subjects " + jQuery("#testSubjectGrid").jqGrid("getCell", idArray[i], "display_content") + " The start time must not be greater than the end date !", " Prompt information ");
                        return;
                    }
                    if ($("#exam_turn_" + idArray[i]).val() == "") {
                        jAlert(" The test subjects " + jQuery("#testSubjectGrid").jqGrid("getCell", idArray[i], "display_content") + " Of the examination session cannot be empty !", " Prompt information ");
                        return;
                    }
                    if ($("#exam_turn_" + idArray[i]).val() != "") {
                        var re = /^[-/+]?/d+(/./d+)?$/;
                        var nubmer = $("#exam_turn_" + idArray[i]).val();
                        if (!re.test(nubmer)) {
                            jAlert(" The test subjects " + jQuery("#testSubjectGrid").jqGrid("getCell", idArray[i], "display_content") + " The number of test sessions must be a number !", " Prompt information ");
                            return false;
                        }
                        if ($("#exam_turn_" + idArray[i]).val().length > 8) {
                            jAlert(" The test subjects " + jQuery("#testSubjectGrid").jqGrid("getCell", idArray[i], "display_content") + " The number of test sessions must not be greater than 8 A digital !", " Prompt information ");
                            return;
                        }
                    }
                }
                if ($("#AddEntranceTestSubjectFrom").validate().form())
                    $("#AddEntranceTestSubjectFrom").ajaxSubmit({
                        url: "/EntryTestsubjectsSet/AddTestSubject/",
                        dataType: 'json',
                        clearForm: false,
                        data: {
                            strJson: JSON.stringify({
                                test_course_id: idArray.join("&")
                            })
                        },
                        success: function (data) {
                            var json = eval("(" + data + ")");
                            jAlert(json.msg, " Prompt information ");
                            if (json.suc == 1) {
                                $("#entranceTestSubjcetMask").hide();
                                $("#entranceAddTestSubjectSet").hide();
                                $("#entranceTestSubjectGrid").trigger("reloadGrid");
                                reloadNum++;
                            }
                        }
                    });
            }
        });
    });

Related articles: