When jqGrid is added-determine the start date and end date (instance resolution)

Source: Internet
Author: User
Tags jqgrid

Copy codeThe Code is as follows:
$ ("# BtnAddSaveTestSubject"). click (function (){
// Add verification and save
JQuery. validator. addMethod ("admissionBatch", function (value, element ){
Return this. optional (element) | value! = 0;
}, "Select enrollment batch ");
JQuery. validator. addMethod ("educationLevel", function (value, element ){
Return this. optional (element) | value! = 0;
}, "Select the education level ");
JQuery. validator. addMethod ("professionalProperty", function (value, element ){
Return this. optional (element) | value! = 0;
}, "Select a professional ");
$ ("# 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: "select enrollment batches ",
AdmissionBatch: "select enrollment batch"
},
"Etsadd_educationLevel ":{
Required: "select the education level ",
EducationLevel: "select education level"
},
"Etsadd_professionalProperty ":{
Required: "select a professional ",
ProfessionalProperty: "select professional"
}
},
SubmitHandler: function (form ){
Var idArray = jQuery ("# testSubjectGrid"). jqGrid ('getgridparam', 'selarrrow'); // obtain the row selected by the test subject
If (idArray = null | idArray = ""){
JAlert ("select test subject! "," Prompt information ");
Return;
}
For (var I = 0; I <idArray. length; I ++ ){
If ($ ("# exam_begintime _" + idArray [I]). val () = ""){
The start time of jAlert ("test subject" + jQuery ("# testSubjectGrid"). jqGrid ("getCell", idArray [I], "display_content") + "cannot be blank! "," Prompt information ");
Return;
}
If ($ ("# exam_endtime _" + idArray [I]). val () = ""){
The end time of jAlert ("test subject" + jQuery ("# testSubjectGrid"). jqGrid ("getCell", idArray [I], "display_content") + "cannot be blank! "," Prompt information ");
Return;
}
Var reg_ymd =/^ ([/d] {4})-([/d] {1, 2})-([/d] {1, 2}) $ /; // validate the regular expression 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 ("test subject" + jQuery ("# testSubjectGrid"). jqGrid ("getCell", idArray [I], "display_content") + "the start time cannot be later than the end date! "," Prompt information ");
Return;
}
If ($ ("# exam_turn _" + idArray [I]). val () = ""){
The number of jAlert ("test subject" + jQuery ("# testSubjectGrid"). jqGrid ("getCell", idArray [I], "display_content") + "test sessions cannot be blank! "," 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 ("test subject" + jQuery ("# testSubjectGrid"). jqGrid ("getCell", idArray [I], "display_content") + "the number of test sessions must be numbers! "," Prompt information ");
Return false;
}
If ($ ("# exam_turn _" + idArray [I]). val (). length> 8 ){
JAlert ("test subject" + jQuery ("# testSubjectGrid "). the number of jqGrid ("getCell", idArray [I], "display_content") + "test sessions cannot exceed 8 digits! "," 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 message ");
If (json. suc = 1 ){
$ ("# EntranceTestSubjcetMask"). hide ();
$ ("# EntranceAddTestSubjectSet"). hide ();
$ ("# EntranceTestSubjectGrid"). trigger ("reloadGrid ");
ReloadNum ++;
}
}
});
}
});
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.