Question

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

Can you help me?

Was it helpful?

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

OTHER TIPS

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."

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top