bootstrap-datapicker 时间约束
<div class="input-group date date-picker" id="StartTime"> <input type="text" class="form-control form-filter input-sm" readonly name="StartTime" placeholder="从" /> <span class="input-group-btn" style="width: 25%"> <button class="btn btn-sm default" type="button"> <i class="fa fa-calendar"></i> </button> </span> </div> <div class="input-group date date-picker" id="EndTime"> <input type="text" class="form-control form-filter input-sm" readonly name="EndTime" placeholder="到"> <span class="input-group-btn" style="width: 25%"> <button class="btn btn-sm default" type="button"> <i class="fa fa-calendar"></i> </button> </span> </div>
$('.date-picker').datepicker({ language: 'zh-CN', todayHighlight: true, format: 'yyyy-mm', autoclose: true, startView: 'months', maxViewMode: 'years', minViewMode: 'months', startDate: "2017-01", endDate: new Date() }); $("#StartTime").on("changeDate",function (e) { var startTime = e.date; $('#EndTime').datepicker('setStartDate',startTime); }); $('#EndTime').on("changeDate",function (e) { var endTime = e.date; $('#StartTime').datepicker('setEndDate',endTime); });