在更改事件的jquery日历中启用禁用日期

时间:2013-10-11 16:58:20

标签: jquery datepicker

我陷入了JQuery日历

我有一个有城市列表的下拉列表

<select name="flyto_code" id="flyto_code">
    <option value="ISB">Islamabad (ISB)</option>
    <option value="KHI">Karachi (KHI)</option>
</select>

我有动态(来自ajax)数组,里面填充了像..

这样的日期
var availableDatesForKhi = ["12-10-2013","13-10-2013","14-10-2013","15-10-2013","16-10-2013","17-10-2013","18-10-2013"];
var availableDatesForIsb = ["12-11-2013","13-10-2013","14-11-2013","15-10-2013","16-11-2013","17-10-2013","18-11-2013"];

当我从Dropbox中选择KHI时,DatePicker应启用availableDatesForKhi

$( "#departure_date" ).datepicker({
beforeShowDay: available,
numberOfMonths:1,
showWeek: true,
dateFormat: 'dd-mm-yy',
showAnim: "slideDown",
onClose: function( selectedDate )
{
$( "#return_date" ).datepicker( "option", "minDate", selectedDate );
}
});


    function available(date)
    {
    dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
    if($.inArray(dmy, availableDatesForKhi ) != -1)
    {
    return [true, "","Available"];
    } 
    else 
    {
    return [false,"","unAvailable"];
    }
    }

我该怎么称呼&amp;创建一个函数

1 个答案:

答案 0 :(得分:0)

您应该查看this answer以约束日期,并在jQuery UI API查看beforeShowDay方法。