簡體   English   中英

使用完整日歷禁用過去的日期和月份

[英]disable the past date and month using 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) {

  }
}

但不起作用,它也會在下個月停用。 如果可能的話在javascript中? 還可以。 演示鏈接

這是一些谷歌代碼片段。

您可以在選擇函數中添加此代碼。

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
}

},

您的情況完全有效。

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
      }
}

請檢查這個小提琴

您可以使用datepicker的minDate屬性來禁用完整日歷的過去日期和過去一個月。

 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' /> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM