winnyboy5
winnyboy5

Reputation: 1516

Completely disabling dates out of the given range

I was using this plugin https://github.com/dangrossman/bootstrap-daterangepicker/ for a daterange picker. I want to completely disable/hide the dates that are out of the given start and end date range. Can some one help me with this please.

  $('#datrange').daterangepicker({
    timePicker: true,
    timePickerIncrement: 30,
    format: 'MM/DD/YYYY h:mm A',
    startDate: moment().subtract('days', 29),
  endDate: moment()
  });

This is the code I use now.

Upvotes: 1

Views: 155

Answers (1)

Cerbrus
Cerbrus

Reputation: 72857

Taking a look at the documentation on the page you linked, I'd say you need these options:

minDate: (Date object, moment object or string) The earliest date a user may select
maxDate: (Date object, moment object or string) The latest date a user may select

Which probably work something like this:

$('#datrange').daterangepicker({
    timePicker: true,
    timePickerIncrement: 30,
    format: 'MM/DD/YYYY h:mm A',
    startDate: moment().subtract('days', 29),
    endDate: moment(),
    minDate: moment().subtract('days', 100),
    maxDate: moment().add('days', 100) // Using moment objects as a example.
});

Upvotes: 1

Related Questions