$ ("# Ets_begindata"). datepicker ({
Dateformat: 'yy-mm-dd ',
Showon: 'click ',
Changemonth: True,
Changeyear: True,
Buttontext: "select ",
Onclose: function (){
$ (This). focusin ();
$ (This). focusout ();
}
});
$ ("# Ets_enddata"). datepicker ({
Dateformat: 'yy-mm-dd ',
Showon: 'click ',
Changemonth: True,
Changeyear: True,
Buttontext: "select ",
Onclose: function (){
$ (This). focusin ();
$ (This). focusout ();
}
});
// Save the modification.
Jquery. validator. addmethod ("checkdata", function (value, element ){
VaR begindate = $ ("# ets_begindata"). Val ();
VaR enddate = $ ("# ets_enddata"). Val ();
VaR dt1 = new date (begindate. Replace (/-/g, "/"); // convert to date type
VaR dt2 = new date (enddate. Replace (/-/g, "/"); // convert to date type
Return this. Optional (element) | dt1 <= dt2;
},"");
Jquery. validator. addmethod ("examvalidate", function (value, element ){
VaR length = value. length;
VaR examnumbids =/^ [-/+]? /D + (/./d + )? $ /;
Return this. Optional (element) | examnumbids. Test (value );
}, "The number of test sessions must be a number ");
$ ("# Entrancetestsubjectfrom"). Validate ({
Event: "Blur ",
Debug: True,
Ignore: ": hidden ",
Errorelement: "Div ",
Wrapper: "Div ",
Errorplacement: function (error, element ){
Error. addclass ('message ');
Error. appendto (element. Parent ());
},
Rules :{
"Ets_begindata ":{
Required: True,
Dateiso: True
},
"Ets_enddata ":{
Required: True,
Dateiso: True,
Checkdata: True
},
"Ets_examid ":{
Required: True,
Maxlength: 8,
Examvalidate: True
}
},
Messages :{
"Ets_begindata ":{
Required: "The start date cannot be blank! ",
Dateiso: "enter a valid date, for example, in the format of (2000-01-01 )"
},
"Ets_enddata ":{
Required: "the end date cannot be blank! ",
Dateiso: "enter a valid date, for example, in the format of (2000-01-01 )",
Checkdata: "the end date must be greater than or equal to the start date"
},
"Ets_examid ":{
Required: "The number of test sessions cannot be blank! ",
Maxlength: "The length of the test session cannot exceed 8 letters ",
Examvalidate: "The number of test sessions must be a number"
}
},
Submithandler: function (form ){
If ($ ("# entrancetestsubjectfrom"). Validate (). Form ())
$ ("# Entrancetestsubjectfrom"). ajaxsubmit ({
URL :"",
Datatype: 'json ',
Data :{
ID: IDS
},
Clearform: false,
Success: function (data ){
VaR JSON = eval ("(" + Data + ")");
Jalert (JSON. MSG, "prompt message ");
If (JSON. suc = 1 ){
$ ("# Grid"). Trigger ("reloadgrid ");
Reloadnum ++;
}
}
});
}
});