1

So the idea is I have 2 datepickers. I want to get the second datepicker minDate value by selecting the first datepicker value. For instance: If I choose the first datepicker value to be 22-03-2015 the second datepicker value will start from 23-03-2015 or If I choose 13-05-2015 the second datepicker value will start from 14-05-2015. How do I achieve that. This is what i tried:

$(".datepicker").datepicker({
     minDate: 'today',
     yearRange: "2015:2016",
     dateFormat: 'dd-mm-yy' 
});
$(".datepicker2").datepicker({
     minDate: 1,
     yearRange: "2015:2016",
     dateFormat: 'dd-mm-yy' 
});
Darren
  • 68,902
  • 24
  • 138
  • 144

2 Answers2

0

You can subscribe to the onSelect event assuming you are using 'jquery datepicker'

JQuery Datepicker onchange event help!

Community
  • 1
  • 1
SkelDave
  • 1,176
  • 2
  • 9
  • 23
0

You can reset the minDate option for datepicker2 after datepicker1's value has changed:

HTML:

<input id="datepicker1" />
<input id="datepicker2" />

jQuery:

$("input").datepicker();

$("#datepicker1").change(function() {
   var minDate = $(this).val();
   $("#datepicker2").datepicker("option", "minDate", minDate);
});

http://jsfiddle.net/ke8LowuL/

Darren
  • 68,902
  • 24
  • 138
  • 144