Reputation:
I have the following JQuery Datepicker
in my page.
$("#<%= txtDate.ClientID %>").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
yearRange: '1901:2050',
maxDate: new Date(),
showOn: "button",
buttonImage: "images/calendar.png",
buttonImageOnly: true,
showButtonPanel: true,
showMonthAfterYear: true,
inline: true,
altField: "#<%= HiddenDate.ClientID %>",
altFormat: "dd-mm-yy",
onSelect: function (dateText, inst) {
shouldsubmit = true;
javascript: __doPostBack('<%= txtDate.ClientID %>', '');
},
onClose: function (dateText, inst) {
shouldsubmit = false;
}
});
It limits my selection to the current date. How do I allow the user to select any future date?
Upvotes: 0
Views: 122
Reputation: 27614
You can set today date is future date ,
$(function() {
$( "#datepicker" ).datepicker({
minDate: -10,
maxDate: new Date()
});
});
Check this demo jsfiddle
Another way you can set +1M
+10D
parameter,
$(function() {
$( "#datepicker" ).datepicker({
minDate: -10,
maxDate: "+1M +10D"
});
});
Check this demo jsfiddle
you can pass yyyy, mm, dd inside date() function to set future date,
$(function() {
$( "#datepicker" ).datepicker({
minDate: -10,
maxDate: new Date(2025, 01,01)
});
});
Check this demo jsfiddle
Hope this help you!
Upvotes: 0
Reputation: 15387
You can set future date limit as follow:
$(function() {
$( "#datepicker" ).datepicker({ minDate: -20, maxDate: "+1M +10D" });
});
Upvotes: 0
Reputation: 5947
This will limit the selection as you mentioned
maxDate: new Date(),
Remove it and you can select any date till the range you have specified.
Upvotes: 1