How to block out dates in the Fullcalendar beyond a certain date

后端 未结 7 1148
心在旅途
心在旅途 2020-12-08 16:51

I have a date in the future which is always 30 days ahead of the current date. It\'s stored in a Date object. I worked this out using:

var currentDate = new          


        
7条回答
  •  遥遥无期
    2020-12-08 17:47

    How about this solution?

    dayClick: function(date, allDay, jsEvent, view) {
       var myDate = new Date();
    
       //How many days to add from today?
       var daysToAdd = 15;
    
       myDate.setDate(myDate.getDate() + daysToAdd);
    
       if (date < myDate) {
           //TRUE Clicked date smaller than today + daysToadd
           alert("You cannot book on this day!");
       } else {
           //FLASE Clicked date larger than today + daysToadd
           alert("Excellent choice! We can book today..");
       }
    
    }
    

提交回复
热议问题