foundation-datepicker
foundation-datepicker copied to clipboard
custom startDate and endDate
Thanks for the nice date picker! Is there a way to limit display of dates to start 7 days from today and end 3 months from now? I noticed that startDate and endDate options accept the value of "today". How could I write startDate:'today' + 7 days? endDate: 'today' + 3 months?
Thanks!
Hi tonumikk,
you can easily achieve this by precalculating the desired date into a variable:
// preparing date variables
var startDate = new Date();
var endDate = new Date();
startDate.setDate(startDate.getDate() + 7);
endDate.setMonth(endDate.getMonth() + 3);
// initializing fdatepicker
$('#dp1').fdatepicker({
startDate: startDate,
endDate: endDate,
format: 'mm-dd-yyyy',
disableDblClickSelection: true,
leftArrow:'<<',
rightArrow:'>>',
closeIcon:'X',
closeButton: true
});