'flatpickr maxDate configuration

How to set maxDate in flatpickr?

<input type="text" id="date-picker" class="form-control" data-toggle="date" placeholder="Select date">

$("#date-picker").flatpickr("minDate", "2019-7-12");

But it is not working.



Solution 1:[1]

Aswin Kumar has the right idea, but you might also need to initialize the new flatpickr. Something like:

function InitFlatPickr() {
  $("#date-picker").flatpickr({
    "minDate": "today",
    "maxDate": "2019-8-12"
  });
}

And then call your InitFlatpickr in either the document ready or something else. The documentation should also be able to help you out.

Solution 2:[2]

For those who are still looking for an answer after reading other solutions... Date must be a date object, not a string!

$("#date-picker").flatpickr({
  minDate: "today",
  maxDate: new Date("2019-08-12") 
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Slimelord
Solution 2 caner