简体   繁体   English

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

[英]Future week disabled in Jquery UI Calender

I need to disabled future weeks for jqueryUI calender, i tried something which is disabled future date. 我需要禁用未来几周的jqueryUI日历,我尝试了禁用未来日期的功能。 but i want future week disable and it's disabled the other dates of week 52 as well. 但我想禁用未来一周,也禁用第52周的其他日期。 please if anyone can help me in this. 请有人在这方面帮助我。 below is link of my work. 以下是我的工作链接。 in this you can see disabled dates of week 52. i want whole week selectable. 在这种情况下,您可以看到第52周的禁用日期。我希望选择整个星期。

Fiddle Link of so far i done. 到目前为止,我已经完成了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');
});

Try this 尝试这个

maxDate: +7 instead of maxDate: new Date maxDate: +7而不是maxDate: new Date

Update 更新

Get the first and last day of current week : 获取本周的第一天和最后一天:

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));

Now you can use them as you want like maxDate: lastday, minDate:firstday 现在,您可以根据需要使用它们,如maxDate: lastday, minDate:firstday

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

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