title: JQuery datepickers- setting end date from a start date
body: <p>There are two Jquery datepickers in use, StartDate and EndDate</p>
  
  <pre><code>&lt;input id="StartDate" class="datepicker setNext hasDatepicker" type="text" value="13/02/2015" name="StartDate"&gt;
  &lt;input id="EndDate" class="datepicker hasDatepicker" type="text" value="15/02/2015" name="EndDate"&gt;
  </code></pre>
  
  <p>When the StartDate datepicker is selected I want the EndDate datepickers to be the StartDate + 1 Day, and to make it so that earlier dates cannot be selected in EndDate than are in StartDate. </p>
  
  <p>I have this code:</p>
  
  <pre><code>$(function () {
      $(".datepicker").datepicker({
          dateFormat: 'dd/mm/yy',
          onSelect: function( selectedDate ) {
              if(this.id == 'StartDate') {
                  var minDate = selectedDate + 1;
                  $('#to').datepicker("option", "minDate", minDate);
  
              }
          }
     });
  });
  </code></pre>
  
  <p>So it hits the onSelect ok, but then the adding 1 to the date doesn't work (I just get the datestring with a 1 on the end, so '31/12/20141'). </p>
  
  <p>I have also tried the following in the OnSelect, assuming that selectedDate was a string not a date type:</p>
  
  <pre><code>                var minDate = new Date(selectedDate);
                  var tomorrow = new Date();
                  tomorrow.setDate(minDate.getDate() + 1);
                  $('#to').datepicker("option", "minDate", tomorrow);
  </code></pre>
  
  <p>minDate ends up being an Invalid Date, as does tomorrow. I can't work out how to set dates from the string. Trying something along the lines of:</p>
  
  <pre><code>var minDate = selectedDate.getDate();
  </code></pre>
  
  <p>Gets me an 'Uncaught TypeError: undefined is not a function'.</p>
  
  <p>Using JQuery 1.11.1, UK date formats of dd/mm/yyyy. </p>