简体   繁体   English

第一个和第三个星期六禁用全日历

[英]First and third saturday disable fullcalendar

I want to disable first and third saturday of the month and I'm using fullcalendar library to show all events on my calendar. 我想禁用该月的第一个和第三个星期六,并且我正在使用fullcalendar库来显示日历中的所有事件。 is it possible to to the same? 有可能一样吗? please advice, answers will be appreciated. 请指教,答案将不胜感激。

Thanks 谢谢

Include Date.js in your project. 在您的项目中包括Date.js。 Now use the following code. 现在使用以下代码。

$(function() {
    $( "#pickdate" ).datepicker({
        dateFormat: 'dd MM yy',
        beforeShowDay: checkBadDates
        });
      }

So here I'm just setting the date format and using the beforeShowDay event to call a function to check if any of the dates should be disabled: 因此,这里我只是设置日期格式,并使用beforeShowDay事件来调用函数以检查是否应禁用任何日期:

var fisrtSaturday=Date.today().first().saturday();  
var thirdSaturday=Date.today().third().saturday();      
var $myBadDates = new Array(fisrtSaturday,thirdSaturday);
function checkBadDates(mydate){
var $return=true;
var $returnclass ="available";
$checkdate = $.datepicker.formatDate('dd MM yy', mydate);
for(var i = 0; i < $myBadDates.length; i++)
   {    
       if($myBadDates[i] == $checkdate)
       {
        $return = false;
        $returnclass= "unavailable";
       }
   }
   return [$return,$returnclass];
   }

This code will disable 1st and 3rd saturday 此代码将禁用第一个和第三个星期六

beforeShowDay : function (date) {
                    var dayOfWeek = date.getDay ();
                    var dateOfMonth = date.getDate();   
                    var weekOfMonth = (dateOfMonth/7);
                    if ( (dayOfWeek == 6 && (weekOfMonth <= 1 || (weekOfMonth == 3 || (weekOfMonth < 3 && weekOfMonth > 2))))) return [false];
                    else return [true];
                },

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

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