How to select between date range on a materialize date picker

Ayberk Yavuz picture Ayberk Yavuz · Jan 20, 2016 · Viewed 12k times · Source

I have a materialize date picker which allows me to select between 10 days in current date.

But i want to select between 16/05/2016, 19/05/2016 dates and other dates will be disabled on the date picker (user cannot select other dates).

My Materialize Date Picker Code :

$('.datepicker').pickadate({   
            selectMonths: true, // Creates a dropdown to control month
            selectYears: 10, // Creates a dropdown of 10 years to control year
            format: 'dd/mm/yyyy',
            min: -10,
            max: true,
            closeOnSelect: true,
            closeOnClear: true,
        });

Answer

Oğuzhan Döngül picture Oğuzhan Döngül · Jan 21, 2016

Did you try this:

$('.datepicker').pickadate({
  min: new Date(2015,3,20),
  max: new Date(2015,7,14)
})

or this:

$('.datepicker').pickadate({
  min: [2015,3,20],
  max: [2015,7,14]
})

Otherwise selectmonths & selectyears may cause problem. If you select only 10 days range, you do not need selecting years or month. Try like this:

$('.datepicker').pickadate({   
    format: 'dd/mm/yyyy',
    min: -10,
    max: true,
    closeOnSelect: true,
    closeOnClear: true,
});

http://amsul.ca/pickadate.js/date/