laydate设置开始时间后,结束时间不可小于已选择的开始时间
laydate设置结束时间后,开始时间不可小于已选择的结束时间
1 //设置开始时间 2 var startDate = laydate.render({ 3 elem: ‘#StartDate‘, 4 done: function (value, date) { 5 if (value !== ‘‘) { 6 endDate.config.min.year = date.year; 7 endDate.config.min.month = date.month - 1; 8 endDate.config.min.date = date.date; 9 } else { 10 endDate.config.min.year = ‘‘; 11 endDate.config.min.month = ‘‘; 12 endDate.config.min.date = ‘‘; 13 } 14 } 15 }); 16 17 //设置结束时间 18 var endDate = laydate.render({ 19 elem: ‘#EndDate‘, 20 done: function (value, date) { 21 if (value !== ‘‘) { 22 startDate.config.max.year = date.year; 23 startDate.config.max.month = date.month - 1; 24 startDate.config.max.date = date.date; 25 } else { 26 startDate.config.max.year = ‘‘; 27 startDate.config.max.month = ‘‘; 28 startDate.config.max.date = ‘‘; 29 } 30 } 31 });
1 <label class="col-sm-2 control-label"><span style="color: red">*</span>开始时间</label> 2 <div class="col-sm-3"> 3 <input class="form-control layer-date" name="StartDate" id="StartDate" placeholder="YYYY-MM-DD" readonly="readonly" /> 4 </div> 5 <label class="col-sm-2 control-label"><span style="color: red">*</span>结束时间</label> 6 <div class="col-sm-3"> 7 <input class="form-control layer-date" name="EndDate" id="EndDate" placeholder="YYYY-MM-DD" readonly="readonly" /> 8 </div>