Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] [request] Date Range Picker Option: MinDateRange #153

Open
jagottsicher opened this issue Jul 8, 2023 · 3 comments
Open

[feature] [request] Date Range Picker Option: MinDateRange #153

jagottsicher opened this issue Jul 8, 2023 · 3 comments

Comments

@jagottsicher
Copy link

jagottsicher commented Jul 8, 2023

the vanillajs-datepicker is awesome.

I'd like to request a feature.

Imagine a hotel using vanillajs-datepicker's the date range picker to let customers choose date ranges for their stay. with minDate option I can prevent people from booking something in the past as long time travel is not invented, but the date-range-picker allows to set a minDate range of 1 day. But hotels usually allow booking a room overnight only - that means start date and end date cannot be the same!

That's a problem in wrapping applications. I have to let the user choose dates and then evaluate the results after submitting. That makes no sense. Better was to have an option:

MinDateRange in Days

Which allows only to choose a minimum number of days after and render that every time the start date is chosen. the end date needs to be set automatically to the minDate + MinDateRange and exclude to choose a end date same as start date.

Or did I overlook an option to achieve that the user can choose a date range of minimum 2 days?

@mymth
Copy link
Owner

mymth commented Jul 22, 2023

I'd like to make sure If my understanding that this is for making DateRangePicker able to work like this https://codepen.io/mymth/pen/eYQjBYm is correct.

Could you please check the quick demo above? Thanks.

@jagottsicher
Copy link
Author

Thanks!

That's exactly the intended behavior I am suggesting!

I tried some different ranges for const minRangeSpan = 5; and it works smootly.
Could not test though if it interfers with a min date or max date if set.

Actually I use the the vanillajs-datepicker in one of my courses because it's so clean and easy to implement. But I had to use a "clumpsy" workaround.

If this features will be implemented I will for sure make use of it.

@mymth
Copy link
Owner

mymth commented Aug 5, 2023

Thank you for confirming. Ah, yeah, I omitted min/maxDate part from the "quick" demo because considering how to implement seemed to be needed.
Anyway, I'll add this feature in a near future version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants