JQuery - 结束日期小于开始日期 100% 工作并且也是动态日期。
对于带有今天日期的显示日期
<script type="text/javascript">
$(document).ready(function () {
$('.bet_start').datepicker({
autoclose: true,
format: 'yyyy-mm-dd',
todayHighlight: true,
startDate: '0d'
});
})</script>
对于结束日期小于开始日期
<script type="text/javascript">
$(document).ready(function () {
$('.bet_start').datepicker({
autoclose: true,
format: 'yyyy-mm-dd',
todayHighlight: true,
startDate: '0d'
});
var startDate = new Date('18/09/2019');
var FromEndDate = new Date();
var ToEndDate = new Date();
ToEndDate.setDate(ToEndDate.getDate() + 365);
$('.bet_start').datepicker({
weekStart: 1,
startDate: '18/09/2019',
endDate: FromEndDate,
autoclose: true
})
.on('changeDate', function (selected) {
startDate = new Date(selected.date.valueOf());
startDate.setDate(startDate.getDate(new Date(selected.date.valueOf())));
$('.bet_end').datepicker('setStartDate', startDate);
});
$('.bet_end')
.datepicker({
weekStart: 1,
startDate: startDate,
endDate: ToEndDate,
autoclose: true
})
.on('changeDate', function (selected) {
FromEndDate = new Date(selected.date.valueOf());
FromEndDate.setDate(FromEndDate.getDate(new Date(selected.date.valueOf())));
$('.bet_start').datepicker('setEndDate', FromEndDate);
});
});</script>