Reputation: 613
EDIT
I have a date picker with the following:
<div class="form-group">
<div class="row">
<div class="col-xs-12 col-sm-5 col-md-4 col-lg-3">
<div class="input-group date" id="datePicker">
@Html.TextBoxFor(m => m.CheckoutDate, new {@id = "checkoutDate", @class = "form-control", @onChange = "Checkout.OnDateChanged()"})
<span class="input-group-addon" style="cursor: pointer;"><span class="glyphicon glyphicon-calendar"></span></span>
</div>
</div>
</div>
</div>
And the date picker is initialized as
$('#datePicker').datepicker({
format: 'yyyy/mm/dd',
todayHighlight: true,
autoclose: true,
startDate: new Date()
});
It works well and disables all past days. I need to now limit the days selectable to x many future days from today. I've tried adding:
maxDate: 2
to the above to limit selection to two days in the future as described in many posts and documentation, but to no affect. This is the first time I'm fiddling with a date picker so chances are I'm just missing something really obvious...
Any suggestions? Thanks.
Upvotes: 0
Views: 1082
Reputation: 613
Using endDate: '+2d'
worked!
Thanks for everyone's suggestions :)
Have a lovely day.
Upvotes: 0
Reputation: 12314
Try the string format for maxDate:
String: A string in the format defined by the
dateFormat
option, or a relative date. Relative dates must contain value and period pairs; valid periods are"y"
for years,"m"
for months,"w"
for weeks, and"d"
for days. For example,"+1m +7d"
represents one month and seven days from today.
$('#datePicker').datepicker({
format: 'yyyy/mm/dd',
todayHighlight: true,
autoclose: true,
startDate: new Date(),
maxDate: "+2d"
});
Upvotes: 2