问题
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