2013-05-21 59 views
1

我使用了「minDate : dateToday」和「minDate : 0」,但之後沒有顯示上一個日期。如何在仍顯示以前日期的同時禁用以前的日期?

例如,如果我輸入今天的日期和明天檢查時,數據庫仍然有昨天的日期,但顯示的日期將是明天。

我該如何解決這個問題?

代碼中使用

$('#startDate,#endDate,#dateEntered').datepicker({ 
     minDate : dateToday, 
     maxDate : "+10Y", 
     buttonImage: "static/images/calender.gif", 
     buttonImageOnly: true, 
     constrainInput: true 
    }); 
+5

您可以通過發佈一些代碼開始。 – j08691

+0

你描述的行爲,因爲我明白這正是我期望datepicker工作。如果你可以提供一個樣本,也許我可以更好地理解你在找什麼。 –

回答

1

工作演示-->http://jsfiddle.net/f6qJF/1/

$('#date').datepicker({ 
    maxDate : "+10Y", 
    buttonImage: "static/images/calender.gif", 
    buttonImageOnly: true, 
    constrainInput: true, 
    beforeShowDay: check 
}); 

function check(date) { 
    if (date > new Date()) return [true]; 
    else return [false]; 
} 
2

我有同樣的問題。我必須使用日期選擇器的beforeShowDay option並刪除mindDate選項。

初始化是這樣的:

$('#startDate,#endDate,#dateEntered').datepicker({ 
     maxDate : "+10Y", 
     buttonImage: "static/images/calender.gif", 
     buttonImageOnly: true, 
     constrainInput: true, 
     beforeShowDay: function(date) { 

      if (date != previousDate && date < dateToday) { //you will need to save the previous date in a variable 
       return [false, "", "Date Unavailable"]; 
      }    
      return [true, ""]; 
     } 
    }); 
相關問題