I have date field which select "Start date" and "End Date", What I wanted to do is to disable the previous date and show from today's date in "Start Date" field, and in "End Date" field, I want to show +3 days, not more than that. I have written my code but it is only working if I select today's date, if I select like 25th September, then it disables all the dates in "End Date". Here goes my code:

```
<div class="row-form clearfix">
<div class="span5">Free Trail Date:</div>
<div class="span7">
<input  value=""  placeholder="From" style="width: 96px;" type="text" name="ftdt" id="dob" required/>
<input  value=""  placeholder="To" style="width: 96px;" type="text" name="ft_snd" id="dob2" required/>
</div>
</div> 

```

JavaScript code:

```
<script>
    $(function() {
        $('#dob').datepicker({
        changeMonth: true, 
        changeYear: true, 
        yearRange: '2012:2020',
        minDate: new Date(),
        onSelect: function(date){

            var selectedDate = new Date(date);
            var msecsInADay = 86400000;
            var endDate = new Date(selectedDate.getTime() + msecsInADay);

            $("#dob2").datepicker( "option", "minDate", endDate );
            $("#dob2").datepicker( "option", "maxDate", '+2d' );
        }
    });
    });
   $(function() {
        $('#dob2').datepicker({changeMonth: true, changeYear: true, 
    yearRange: '2012:2020'});
   });
</script>

```

Please help me where I am getting wrong, my code is working if I select today's date, but when I select advanced days, it disables the "End Date" field.