簡體   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