question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Range mode of Flatpickr with limits (min and max) for choosing dates

See original GitHub issue

Hello! Thanks for your work.

It would be nice to be able to set for mode: "range", which would create the minimum and/or maximum length of the date range choice.

That is, with such options…

{
   ...
   minRange: 3,
   maxRange: 10,
   ...
}

…it would not be possible to select a date range that would be less than the specified minimum number of (3 days), but not more than the maximum number (10 days).

This would solve many problems. Both mine and many people!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:12
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
spektra2147commented, Apr 30, 2020

Convert Timestamp `$(function () {

flatpickr(".filter-date", {
    mode: $(this).attr('mode'),
    enableTime: true,
    disableMobile: "true",
    time_24hr: true,
    maxRange: 10,
    defaultDate: nowDateTime,
    dateFormat: "m.d.Y H:i:ss",
    onChange: function (selectedDates, dateStr, instance) {
        if (selectedDates.length > 1) {
            var range = instance.formatDate(selectedDates[1], 'U') - instance.formatDate(selectedDates[0], 'U');
            range = range / 86400;

            if(range > 30)
            {
                alert("Max: 30 Days");
                instance.clear()
            }
        }
    },
});

}); `

7reactions
bethbryerscommented, Jan 31, 2020

Are there any updates on this, would be great to have a minRange/maxRange option either as a plugin or as part of the core!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Options - Flatpickr
Config Option Type Default altFormat String "F j, Y" altInput Boolean false altInputClass String ""
Read more >
Flatpickr - Limit the amount of dates that can be selected
This date picker allows for multiple dates to be selected but after reading the docs I can't find any way to limit the...
Read more >
flatpickr - lightweight datetimepicker & calendar - UNPKG
Basic · Make it a datetime picker · Display a human-readable date · Limit the range of available dates with minDate and maxDate...
Read more >
Selecting a Range of Dates - Integrating Flatpickr.js
You can have the user select a range of dates by passing in the property of mode: "range". Name. Email Address. Date.
Read more >
Range mode of Flatpickr with limits (min and max) for ...
It would be nice to be able to set for mode: "range" , which would create the minimum and/or maximum length of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found