0
我想從jQuery datepicker禁用某些日期。我知道這個問題是經常討論的,但通常只針對常規日期,如假期或週末。我想從MySQL表中拉出日子。爲了禁用常規日期,代碼是;在jQuery datepicker中禁用日期與MySQL日期
$(function() {
$("#datepickerthing").datepicker({
altField: '#actualDate',
minDate:'0',
maxDate: '+6M',
beforeShowDay: nationalDays
});
var natDays = ["4/22/2009","4/23/2009","4/24/2009","4/25/2009","4/26/2009","5/27/2009","5/28/2009","6/26/2009","6/27/2009","6/28/2009","6/29/2009","6/30/2009"];
function nationalDays(date) {
var sDate = (date.getMonth()+1).toString() + "/" + date.getDate().toString() + "/" + date.getFullYear().toString();
if ($.inArray(sDate, natDays) != -1) return [false,"","Not this day!"];
else return [true, ""];
}
});
我不明白的是如何獲得日期的字符串從數據庫到變量「natDays」,並確保它們的格式正確。
在此先感謝任何人可以提供的幫助。