Kendo DatePicker禁用日期jQuery

时间:2016-07-08 16:51:00

标签: javascript jquery kendo-ui kendo-datepicker

我的页面上有一个日期选择器,我试图禁用除星期日之外的所有日期,当时在Kendo Drop Down中选择了一个值。我的功能如下。该函数被调用,但我不知道如何或如果我可以这样设置禁用日期。任何人都可以指出我正确的语法方向吗?

我试过了

function dropdownChanged() {

    var startdate = $("#startdate").data("kendoDatePicker");

    //tried this with no luck
    var start_disabled = ["mo", "tu", "we", "th", "fr", "sa"];
    startdate.disableDates(start_disabled);

}

谢谢!

1 个答案:

答案 0 :(得分:1)

请参阅文档here

<input id="datepicker" />
<script>
$("#datepicker").kendoDatePicker({
    value: new Date(),
    disableDates: function (date) {
        var disabled = [13,14,20,21];
        if (date && disabled.indexOf(date.getDate()) > -1 ) {
            return true;
        } else {
            return false;
        }
    }
});
</script>


<input id="datepicker" />
<script>
$("#datepicker").kendoDatePicker({
    value: new Date(),
    disableDates: ["we", "th"],
});
</script>