London Smith London Smith - 2 months ago 8
jQuery Question

Datemin for bootstrap-datepicker does not work

Can't find a way to set a minDate and by the way a maxDate for bootstrap-datepicker v1.6.1.

What I tried:

$("#dateStart").datepicker({
minDate: 0,
startView: 2
});

$("#dateEnd").datepicker({
minDate: "25/02/2016",
startView: 2
});


An example here: http://www.bootply.com/iNV8YltUmf

What is the right way to set minDate and maxDate ?

Thanks.

Answer

With the documentation that is provided with your bootply.. there are not any options that include minDate and maxDate... But there are startDate and endDate.

So your code should look like this:

$("#dateStart").datepicker({
    startDate: '10/01/2016', // as an example
    startView: 2
});

$("#dateEnd").datepicker({
    endDate: '10/06/2016', // as an example
    startView: 2
}); 

Here is your bootply to show you.

Hope this helps!