How to select between date range on a materialize date picker

12,441

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/

Share:
12,441
Ayberk Yavuz
Author by

Ayberk Yavuz

Updated on July 22, 2022

Comments

  • Ayberk Yavuz
    Ayberk Yavuz almost 2 years

    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,
            });