简体   繁体   中英

disable the past date and month using full calendar

How to disable the past date and the past month using full calendar in select option I tried out with this function in full calendar

select: function(start, end, allDay) {
  var check = $.fullCalendar.moment(start).format('DD-MM-YYYY');
  var today = $.fullCalendar.moment(new Date()).format('DD-MM-YYYY');
  if (check >= today) {

  }
}

but not working, it disables next month also. if it possible in javascript? also it fine. Demo link

Here is some googled code snippet.

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. 
}
else
{
    // Right Date
}

},

Your condition totally works.

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) {
      // True conditions
      }
}

Please check this fiddle

You can disabling past date and the past month of a full calendar using minDate attribute of datepicker.

 var dateToday = new Date(); $('#visit').datepicker({ minDate: dateToday }); 
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script> <link href="https://davidwalsh.name/demo/jquery-ui-css/custom-theme/jquery-ui-1.7.2.custom.css" rel="stylesheet"/> <input type='text' id='visit' /> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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