Reputation: 199
I need to enable only next two months in date picker. like if current month is February,then only march and April should enable in date picker.all other month should disable.
I have tried number of Months, but it shows two months inline.I don't want to display like this.
I have tried this,
minDate: '0',
maxDate: '+2m+30d',
but, it changes according to date,
I need only two months exactly from current month.
Is there any other solution for this ?
Upvotes: 0
Views: 5799
Reputation: 2498
try code or go to the link
HTML-
<input id="date" />
JAVASCRIPT-
$("#date").datepicker({
changeMonth: true,
changeYear: true,
minDate:0,
maxDate: "+3M"
}).datepicker('setDate', new Date());
Upvotes: 0
Reputation: 1198
Do something like following
$(function () {
$("#txtFrom").datepicker({
minDate: new Date(),
maxDate: new Date(new Date().setMonth(new Date().getMonth() + 2))
});
});
<link href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<input type="text" id="txtFrom" />
Upvotes: 2
Reputation: 396
Try this. You are adding +30d as well . which will be 3 months from today . also i guess space would be required between '+2m +30d'
$( "#datepicker" ).datepicker({ maxDate: "+2M" });
Upvotes: 0