Reputation: 6639
I have a from date and to date. I want the todate to start with the day fromdate is chosen. For example: if I choose from date to be 7th Jan, 2015, I want the datepicker to show the todate from 7th Jan, 2015 onwards and not anything before that. How do I achieve it?
<script type="text/javascript">
$(document).ready(function(){
$("#from_date").datepicker({
maxDate: -1,
minDate: "2015-01-01",
dateFormat:"yy-mm-dd"
});
$("#to_date").datepicker({
maxDate: -1,
minDate: "2015-01-01",
dateFormat:"yy-mm-dd"
});
});
</script>
Upvotes: 0
Views: 60
Reputation: 261
$(function() {
$( "#from" ).datepicker({
changeMonth: true,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
changeMonth: true,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
Demo.
Upvotes: 3