Saika
Saika

Reputation: 396

jQuery Ui Calendar

I want change maxDate with addition of minDate and 1 weak but, It find maxDate from current day, please help me, how can I Change maxDate through minDate, here is code

  $( function() {
    $("#datepicker")
   .datepicker({
    dateFormat:'yy-mm-dd',
     minDate:new Date('2018-05-7'),
     defaultDate: "+2m",
     changeMonth: 1,
     numberOfMonths: 1,
     maxDate: '+8d',
     showOtherMonths: true,
     selectOtherMonths: true,
})

  } );

Upvotes: 0

Views: 42

Answers (1)

Mb...R
Mb...R

Reputation: 78

You can use the following to calculate endDate and provide these two dates as min and max date for datepicker

var startDate= new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - new Date().getDay()); //this week startDate
var endDate= new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() + 8); // add 8 days to current date

Upvotes: 1

Related Questions