繁体   English   中英

未来一周将在Jquery UI日历中禁用

[英]Future week disabled in Jquery UI Calender

我需要禁用未来几周的jqueryUI日历,我尝试了禁用未来日期的功能。 但我想禁用未来一周,也禁用第52周的其他日期。 请有人在这方面帮助我。 以下是我的工作链接。 在这种情况下,您可以看到第52周的禁用日期。我希望选择整个星期。

到目前为止,我已经完成了Fiddle Link。

<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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM