我正在运行uxsolutions / bootstrap-datepicker(https://github.com/uxsolutions/bootstrap-datepicker)。
我已经在弹出日历窗口小部件中禁用了日期(请参阅下面的代码)。然而在日期的文本框中,我可以输入一个禁用日期(下面的屏幕截图)。
如何让日期框识别禁用日期并阻止它们被输入?
$('#eventDate-container .input-group.date').datepicker({
weekStart: 1, // calendar starts on Monday
autoclose: true,
todayHighlight: true,
startDate: "4/10/2017", // disables all dates prior to this date
datesDisabled: ['01/01/1970', '12/31/2099'] // placeholder sample for possible future use
});
答案 0 :(得分:1)
我知道这不是你正在使用的插件(Bootstrap 3 Date/Time Picker),但这可能会有所帮助...... 今天我一直在做同样的事情,我开始使用您正在使用的确切插件,但后来转到Bootstrap 3 Date/Time Picker,因为它有更多选项
Disable manual entry of date in , force selection via picker. #212
答案 1 :(得分:0)
我修补了代码:
keydown: function(e){
case 13: // enter
if (!this.o.forceParse)
break;
**if (this.picker.find('td.focused.day').hasClass('disabled'))
break;**
focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
if (this.o.keyboardNavigation) {
this._toggle_multidate(focusDate);
dateChanged = true;
}