Search code examples
jquerydatepickertwitter-bootstrap-3bootstrap-datepicker

Custom available dates bootstrap datepicker


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

Can you help me?


Solution

  • 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