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!
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
Try something like:
jQuery("#date").datepicker({
beforeShow: function() {
return {
dateFormat: 'yy-mm-dd',
minDate: '2012-12-10',
maxDate: '2012-12-20',
}
}
});
Use maxDate
and minDate
options when creating.
Code:
$( "#datepicker" ).datepicker({ minDate: value1, maxDate: value2 });
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.