Reputation: 179
Can you please show me how to enable range in jquery ui datepicker, I want to determine range in the format: from 2012-12-10 to 2012-12-20 etc (yy-mm-dd, already specified). All other dates should not be available.
Appreciate the help I can get, cheers!
Upvotes: 1
Views: 19568
Reputation: 2403
The previous answer is correct, example:
$(function() {
$( "#datepicker" ).datepicker({ minDate: new Date(2012, 12, 10), maxDate: new Date(2012, 12, 20) });
});
I just wanted to add the following links which you might find useful:
http://jqueryui.com/datepicker/#min-max
http://api.jqueryui.com/datepicker/
Upvotes: 0
Reputation: 2631
try this:
function setInterval(){
$(function() {
$( "#startDate" ).datepicker({
defaultDate: "+1w",
onSelect: function( selectedDate ) {
$( "#endDate" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#endDate" ).datepicker({
defaultDate: "+1w",
onSelect: function( selectedDate ) {
$( "#startDate" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
}
where
startDate
endDate
are the two input fields of datepicker
Upvotes: 6
Reputation: 16223
Try something like:
jQuery("#date").datepicker({
beforeShow: function() {
return {
dateFormat: 'yy-mm-dd',
minDate: '2012-12-10',
maxDate: '2012-12-20',
}
}
});
Upvotes: 1