Skip to content
Advertisement

How to set a minimum date range limit for the Date Range Picker

I am using the Date Range Picker from daterangepicker.com. How can I set a minimum date range limit for this Date Range Picker? For example, I want to set minimum limit of 3 days so the user can only select a date range of 3 days or more.

At the moment my code for the date range picker is just simply instantiating it with:

$('input[name="daterange"]').daterangepicker();

Advertisement

Answer

Here’s one option that seems to work. Note that it doesn’t block out dates or give any notification to the user, it just forces the date range to be a certain length (if user selects shorter, it changes the end date to the minimum length based on start date & min length)

https://github.com/dangrossman/daterangepicker/pull/1731/files

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement