Jquery UI 日历中禁用未来一周
Future week disabled in Jquery UI Calender
我需要为 jqueryUI 日历禁用未来几周,我尝试了一些禁用未来日期的东西。但我希望禁用未来一周,并且在第 52 周的其他日期也禁用它。如果有人可以帮助我,请帮助我。以下是我的 link 作品。在此您可以看到第 52 周的禁用日期。我希望整个星期都可以选择。
<input type="text" class="form-control weekcal-x" name="start" id="start" custom="" />
$(".weekcal-x").datepicker({
showWeek: true,
firstDay: 1,
maxDate: new Date,
onSelect: function(dateText, inst) {
$(this).val("Week " + $.datepicker.iso8601Week(new Date(dateText)) + ', ' + $.datepicker.formatDate("yy", new Date(dateText)));
}
}).datepicker('widget').addClass('ui-weekpicker');
$('.ui-weekpicker').on('mousemove', 'tr', function() {
$(this).find('td a').addClass('ui-state-hover');
});
$('.ui-weekpicker').on('mouseleave', 'tr', function() {
$(this).find('td a').removeClass('ui-state-hover');
});
试试这个
maxDate: +7
而不是 maxDate: new Date
更新
获取本周的第一天和最后一天:
var currentDate = new Date; // get current date
var first = currentDate.getDate() - currentDate.getDay() + 1; // First day is the day of the month - the day of the week
var last = first + 6; // last day is the first day + 6
var firstday = new Date(currentDate.setDate(first));
var lastday = new Date(currentDate.setDate(last));
现在您可以随心所欲地使用它们了 maxDate: lastday, minDate:firstday
我需要为 jqueryUI 日历禁用未来几周,我尝试了一些禁用未来日期的东西。但我希望禁用未来一周,并且在第 52 周的其他日期也禁用它。如果有人可以帮助我,请帮助我。以下是我的 link 作品。在此您可以看到第 52 周的禁用日期。我希望整个星期都可以选择。
<input type="text" class="form-control weekcal-x" name="start" id="start" custom="" />
$(".weekcal-x").datepicker({
showWeek: true,
firstDay: 1,
maxDate: new Date,
onSelect: function(dateText, inst) {
$(this).val("Week " + $.datepicker.iso8601Week(new Date(dateText)) + ', ' + $.datepicker.formatDate("yy", new Date(dateText)));
}
}).datepicker('widget').addClass('ui-weekpicker');
$('.ui-weekpicker').on('mousemove', 'tr', function() {
$(this).find('td a').addClass('ui-state-hover');
});
$('.ui-weekpicker').on('mouseleave', 'tr', function() {
$(this).find('td a').removeClass('ui-state-hover');
});
试试这个
maxDate: +7
而不是 maxDate: new Date
更新
获取本周的第一天和最后一天:
var currentDate = new Date; // get current date
var first = currentDate.getDate() - currentDate.getDay() + 1; // First day is the day of the month - the day of the week
var last = first + 6; // last day is the first day + 6
var firstday = new Date(currentDate.setDate(first));
var lastday = new Date(currentDate.setDate(last));
现在您可以随心所欲地使用它们了 maxDate: lastday, minDate:firstday