【第十九篇】laydate设置起始时间,laydate设置开始时间和结束时间

时间:2022-11-13 05:41:26

laydate设置开始时间后,结束时间不可小于已选择的开始时间

laydate设置结束时间后,开始时间不可小于已选择的结束时间

         //设置开始时间
var startDate = laydate.render({
elem: '#StartDate',
done: function (value, date) {
if (value !== '') {
endDate.config.min.year = date.year;
endDate.config.min.month = date.month - 1;
endDate.config.min.date = date.date;
} else {
endDate.config.min.year = '';
endDate.config.min.month = '';
endDate.config.min.date = '';
}
}
}); //设置结束时间
var endDate = laydate.render({
elem: '#EndDate',
done: function (value, date) {
if (value !== '') {
startDate.config.max.year = date.year;
startDate.config.max.month = date.month - 1;
startDate.config.max.date = date.date;
} else {
startDate.config.max.year = '';
startDate.config.max.month = '';
startDate.config.max.date = '';
}
}
});
 <label class="col-sm-2 control-label"><span style="color: red">*</span>开始时间</label>
<div class="col-sm-3">
<input class="form-control layer-date" name="StartDate" id="StartDate" placeholder="YYYY-MM-DD" readonly="readonly" />
</div>
<label class="col-sm-2 control-label"><span style="color: red">*</span>结束时间</label>
<div class="col-sm-3">
<input class="form-control layer-date" name="EndDate" id="EndDate" placeholder="YYYY-MM-DD" readonly="readonly" />
</div>

---------------------------------------------------------------------------------------------------------

转载请记得说明作者和出处哦-.-
作者:KingDuDu
原文出处:https://www.cnblogs.com/kingdudu/articles/8529094.html

---------------------------------------------------------------------------------------------------------