jquery datepicker: select date as back as 6 months
        Posted  
        
            by Abu Hamzah
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Abu Hamzah
        
        
        
        Published on 2010-04-23T19:33:07Z
        Indexed on 
            2010/04/24
            1:03 UTC
        
        
        Read the original article
        Hit count: 419
        
jQuery
|datepicker
Start date: user can select start date as back as 6 months. example: if today is 04/23/2010 then i can go back up to 11/23/2009 but not more than 6 months.
<script type="text/javascript"> 
$(document).ready(function () { 
  $('#endDate').datepicker({ showOn: 'button', 
      buttonImage: '../images/Calendar.png', 
      buttonImageOnly: true, onSelect: function () { }, 
      onClose: function () { $(this).focus(); } 
    }); 
  $('#startDate').datepicker({ showOn: 'button', 
      buttonImage: '../images/Calendar.png', 
      buttonImageOnly: true, onSelect: 
        function (dateText, inst) { 
          $('#endDate').datepicker("option", 'minDate', new Date(dateText)); 
        } 
      , 
      onClose: function () { $(this).focus(); } 
    }); 
}); 
update code:
   var currentDate = new Date();
    var currentMonth = currentDate.getMonth() + 1;
    var sixMonths = currentMonth + 6 
    currentDate.setMonth(currentDate.currentMonth, sixMonths);
    var myNewCurrentDate = new Date(currentDate)
    $('#startDate').datepicker('option', { minDate: myNewCurrentDate });
i am getting currentDate = NaN
© Stack Overflow or respective owner