datepicker 时间约束 - 起始时间和结束时间
$("#date").datepicker({
language: "zh-CN",
autoclose: true,
todayHighlight: 1,
startDate: dt
});
todayHighlight : 今天高亮显示
startDate: 起始时间
endDate: 结束时间
先看一下源码里的参数:
var defaults = $.fn.datepicker.defaults = {
autoclose: false,
beforeShowDay: $.noop,
beforeShowMonth: $.noop,
beforeShowYear: $.noop,
calendarWeeks: false,
clearBtn: false,
toggleActive: false,
daysOfWeekDisabled: [],
daysOfWeekHighlighted: [],
datesDisabled: [],
endDate: Infinity, // 结束时间
forceParse: true,
format: 'mm/dd/yyyy',
keyboardNavigation: true,
language: 'en',
minViewMode: 0,
maxViewMode: 2,
multidate: false,
multidateSeparator: ',',
orientation: "auto",
rtl: false,
startDate: -Infinity, // 起始时间
startView: 0,
todayBtn: false,
todayHighlight: false,
weekStart: 0,
disableTouchKeyboard: false,
enableOnReadonly: true,
showOnFocus: true,
zIndexOffset: 10,
container: 'body',
immediateUpdates: false,
title: ''
};
举个简单的例子:
明天后可选
var tomorrowDate = new Date(new Date().setDate(new Date().getDate() + 1));
$("#date").datepicker({
language: "zh-CN",
autoclose: true,
todayHighlight: 0, // 取现当天高亮
startDate: tomorrowDate
});
结束时间同理。