title: jQuery datepicker- 2 inputs/textboxes and restricting range
body: <p>I am using the jQuery Datepicker widget with two input boxes, one for the <strong>"From"</strong> date and the second with the <strong>"To"</strong> date. I am using the <a href="http://jqueryui.com/datepicker/" rel="noreferrer">jQuery Datepicker functional demo</a> as a basis for getting the two input boxes to work with each other, but I need to be able to add these additional restrictions:</p>
  
  <ol>
  <li><p>Date range can be no earlier than
  01 December 2008 </p></li>
  <li><p><strong>"To"</strong> date can be no
      later than today</p></li>
  <li><p>Once a <strong>"From"</strong> date
      is selected, the <strong>"To"</strong> date can only
      be within a range of 7 days after
      the <strong>"From"</strong> date</p></li>
  <li><p>If a <strong>"To"</strong> date is
      selected first, then the <strong>"From"</strong> date
      can only be within the range of 7
      days before the <strong>"To"</strong> date (with the
      limit of 01 December being the first
      selectable date)</p></li>
  </ol>
  
  <p>I can't seem to get all of the above working together.</p>
  
  <p>In summary, I would like to be able to select a range of up to 7 days between 01 December and today (I realise I am posting this on 1st December so will only get today for the moment).</p>
  
  <p>My code so far</p>
  
  <pre><code>$(function () {
  
  $('#txtStartDate, #txtEndDate').datepicker(
              {
              showOn: "both",
              beforeShow: customRange,
              dateFormat: "dd M yy",
              firstDay: 1, 
              changeFirstDay: false
              });
  });
  
  function customRange(input) 
  { 
  
  return {
           minDate: (input.id == "txtStartDate" ? new Date(2008, 12 - 1, 1) : null),
           minDate: (input.id == "txtEndDate" ? $("#txtStartDate").datepicker("getDate") : null), 
           maxDate: (input.id == "txtStartDate" ? $("#txtEndDate").datepicker("getDate") : null)
         }; 
  }
  </code></pre>
  
  <p>I'm missing the 7 day range restriction and also preventing a <strong>"To"</strong> date selection before 01 December 2008 or after today. Any help would be much appreciated, Thanks.</p>