我想在过去的几天中禁用所有类型的操作。

这是我尝试过的:

http://jsfiddle.net/7MTdn/275/

我也在这里提供我的代码:

$('#mycalendar').fullCalendar(
            {
             header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay'
                    },


                dayClick: function( date, allDay, jsEvent, view ) {

                                    var getFromDate = date.getFullYear()+'-'+parseInt(date.getMonth()+1)+'-'+date.getDate();

                var newDate = new Date();
                var newD    = newDate.getDate();
                var newM    = newDate.getMonth();
                var newY    = newDate.getFullYear();

                var myDate  = newY+'-'+newM+'-'+newD;

                alert(Number(myDate));

                alert(Number(getFromDate));

                if(getFromDate<myDate)
                {
                    alert("Sorry! You cannot add event on past dates.");
                    return false;
                }
                else
                {
                    alert("You can add an event on this date");
                }


            },

             events: [

                        {
                            title  : 'eventTest',
                            start  : '2013-12-18',
                            end    : '2013-12-26'
                        }
                    ]
           });

最佳答案

我认为cond需要点这样的东西..

     var getFromYr = date.getFullYear();
                var getFromMonth= date.getMonth()+1;
                 var getFromDay =  date.getDate();

            var newDate = new Date();
                var newD = newDate.getDate();
                var newM = newDate.getMonth()+1;
                var newY = newDate.getFullYear();
         if(getFromYr<newY || (getFromYr==newY && getFromMonth<newM) ||(getFromMonth==newM && getFromDay <newD)  )
            {
                alert("Sorry! You cannot add event on past dates.");
                return false;
            }


Fiddle Demo

09-25 17:08