Custom available dates bootstrap datepicker

☆樱花仙子☆ 提交于 2020-01-16 00:45:35

问题


I'm trying to show only custom dates with bootstrap datepicker: http://bootstrap-datepicker.readthedocs.org/en/latest/index.html.

Can you help me?


回答1:


You can use beforeShowDay:

var dateDisabled = ["2014-5-5", "2014-5-6"];
$(function(){
    $('.datepicker').datepicker(
    {
        format: 'yyyy-mm-dd',
        beforeShowDay: function(date)
        {
            if ($.inArray(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate(), dateDisabled) !== -1)
            {
                return;
            }

            return false;
        }
    });
});

Live demo




回答2:


The answer is available under that link:

http://www.eyecon.ro/bootstrap-datepicker/

Look for the section "Disabling dates in the past and dependent disabling."




回答3:


I think instead disable past/future dates you mean enable only some picked dates, like events in a calendar. And yes: even this is possible providing an available function: Bootstrap Datepicker restrict available dates to be selected



来源:https://stackoverflow.com/questions/23456021/custom-available-dates-bootstrap-datepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!