How to make past date unselectable in fullcalendar?

前端 未结 15 1275
暗喜
暗喜 2020-12-08 07:46

Problem is, how to disable selectable on PAST DATES in fullcalendar\'s month/week view.

I want to user not allowed to click/select the on past dates.

15条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 08:25

    I have done this in my fullcalendar and it's working perfectly.

    you can add this code in your select function.

     select: function(start, end, allDay) {
        var check = $.fullCalendar.formatDate(start,'yyyy-MM-dd');
        var today = $.fullCalendar.formatDate(new Date(),'yyyy-MM-dd');
        if(check < today)
        {
            // Previous Day. show message if you want otherwise do nothing.
            // So it will be unselectable
        }
        else
        {
            // Its a right date
            // Do something
        }
      },
    

    I hope it will help you.

提交回复
热议问题