title: jQuery datepicker: Limit date from selectedDate
body: <p>I'd like to restrict my calendar for users to limit date range.</p>
  
  <p>For example: if a user select March 10th 2014 at From, then the user must not select after June 10th 2014 at To.</p>
  
  <p>Here is the code I've made:</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>$(function() {
     $( "#from" ).datepicker({
        maxDate: 0,
        dateFormat : 'dd-mm-yy',
        onClose: function( selectedDate ) {
          $( "#to" ).datepicker( "option", "minDate", selectedDate );
          var date = $(this).datepicker('getDate');
          var maxDate = new Date(date.getMonth() + 3);
          $( "#to" ).datepicker( "option", "maxDate", maxDate );
        }
      });
  
      $( "#to" ).datepicker({
          maxDate: 0,
          onClose: function( selectedDate ) {
            $( "#from" ).datepicker( "option", "maxDate", selectedDate );
          }
      });
  }
  </code></pre>