Require Date:<inputclass= "Easyui-datebox"data-options= "Formatter:myformatter,parser:myparser,onselect:selectstartdate"style= "width:110px"ID= "StartTime">To :<inputclass= "Easyui-datebox"data-options= "Formatter:myformatter,parser:myparser,onselect:selectenddate"style= "width:110px"ID= "EndTime">
$ (function () { // $ (' #EndTime '). Datebox (). Datebox (' Calendar ' '). Calendar ({validator: function (StartDate) { return startdate <= Date (); } });})
//Easyui Official Rewrite time format methodfunctionMyFormatter (date) {vary =date.getfullyear (); varm = date.getmonth () + 1; varD =date.getdate (); returnY + '-' + (M < 10?) (' 0 ' + m): m) + '-' + (D < 10?) (' 0 ' +d): D);}functionMyparser (s) {if(!s)return NewDate (); varSS = (S.split ('-'))); vary = parseint (ss[0], 10); varm = parseint (Ss[1], 10); varD = parseint (ss[2], 10); if(!isnan (Y) &&!isnan (m) &&!IsNaN (d)) { return NewDate (Y, m-1, D); } Else { return NewDate (); }}//limit the range of end dates when the start date is selectedfunctionselectstartdate (startdate) {//return calendar will empty the Endtime content, need to save the next varTempenddate = $ (' #EndTime '). Datebox (' GetValue ')) $(' #EndTime '). Datebox (). Datebox (' Calendar '). Calendar ({validator:function(endDate) {//Limited Date selection range returnEndDate >= startdate && endDate <=NewDate (); } }); //write the Endtime back .$ (' #EndTime '). Datebox (' SetValue '), tempenddate);}//limit the range of start dates when the end date is selectedfunctionselectenddate (endDate) {varTempstartdate = $ (' #StartTime '). Datebox (' GetValue ')); $(' #StartTime '). Datebox (). Datebox (' Calendar '). Calendar ({validator:function(startdate) {returnStartDate <= endDate && startdate <=NewDate (); } }); $(' #StartTime '). Datebox (' SetValue '), tempstartdate);}
Easyui Datebox limit Time selection range