Reputation: 91
I'm using Bootstrap datepicker and I'd like to make that when datepicker shows, default date would be set after 14 days from today. I've got this code but it doesn't work, default date is still set to today. Could anyone explain what am I missing? Thanks in advance.
JS:
var plus14days = new Date();
plus14days.setDate(plus14days.getDate() + 14 );
$(".datepicker").datepicker("setValue", plus14days);
Upvotes: 9
Views: 30473
Reputation: 501
var plus14days = new Date();
plus14days.setDate(plus14days.getDate() + 14 );
$('.datepicker').data("date", plus14days);
$(".datepicker").datepicker();
You can try to set the default date in datepicker data and then initialize the datepicker. This worked for me.
Upvotes: 0
Reputation: 1260
Just a consideration, api changed setValue to setDate (http://bootstrap-datepicker.readthedocs.org/en/release/methods.html#setdate)
Upvotes: 4