title: 2 dependent datepickers with min and max date
body: <p>I'm looking to build a form with 2 datepickers. The chosen data of the first one, must be the minDate of the second one and the maxDate of the second one must be the minDate+10 days.</p>
  
  <p>For example:</p>
  
  <ul>
  <li>first date selected: 01/01/2019</li>
  <li>In the second field I can choose maximum the 01/10/2019 as date</li>
  </ul>
  
  <p>Here is my little code I've done just now:</p>
  
  <pre><code>$(document).ready(function () {
  
      $("#from").datepicker({
          dateFormat: "dd-mm-yy",
          minDate: 0,
          onSelect: function (date) {
              var date2 = $('#from').datepicker('getDate');
              date2.setDate(date2.getDate() + 10);
              $('#to').datepicker('setDate', date2);
              //sets minDate to from date + 1
              $('#to').datepicker('option', 'minDate', date2);
          }
      });
      $('#to').datepicker({
          dateFormat: "dd-mm-yy",
          onClose: function () {
              var from = $('#from').datepicker('getDate');
              console.log(from);
              var to = $('#to').datepicker('getDate');
              if (to &lt;= from) {
                  var minDate = $('#to').datepicker('option', 'maxDate');
                  $('#to').datepicker('setDate', minDate);
              }
          }
      });
  });
  </code></pre>