-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Disabled dates for input type=date #9542
Comments
All of your use cases would end up with an extremely long list of disallowed dates, I'm not sure if this proposal makes sense for these cases. |
My case is only an example. The point is to disable any arbitrary collection of dates, not to disable public holidays specifically. What those dates are in practice, is up to business rules to decide, or some kind of event calender, a user preference of some kind, or whatever else. Arbitrary. When disabling dates, it's usually because some kind of business or service is not available on that date. With that, it makes to also specify min/max dates, and then the number of public holidays listed, and any other disallowed dates, could well be a rather small list. Another option would be to make it an event: <input type=date ondatedisabled="disabledDate">
<script>
function disabledDate(date) {
if (!isBusinessAvalableOnThisDate(date)) {
return false;
}
}
</script> (edit: must've been drunk - the script now makes sense) |
A syntax like |
Allowing days of the week and wildcards would go a long way towards making this manageable. (Possibly not far enough, but still a lot...) |
Yes, wildcards would prove to be quite helpful. But again, it's an example. What I'm referring to, is an arbitrary list of dates. Perhaps coming from a backend system of some kind, or otherwise precalculated by something before the HTML gets rendered. So a list of fully defined dates is still desirable. |
Restricting date picking on a day bases is in my opinion a pretty good approach. First idea that came to my mind was to assign days of the week number values (Monday=0, Tuesday=1, Wednesday=2, Thursday=3, Friday=4, Saturday=5, Sunday=6) and have a special attribute called This is a code example for blocking Monday, Saturday and Sunday:
|
Just curious if this suggestion has any traction. I work for a bank and need to be able to exclude weekends and holidays for certain transactions. I'd love to not have to resort to a large package like react-datepicker and be able to stick with native elements. |
As a follow up to today's WHATNOT meeting, here are a few examples of how Javascript datepickers handle disabled dates. Some accept an array of dates to disable. And some accept a function that returns a boolean. I think that @thany and @EziKielCroat both suggest ideal API examples and perhaps two attributes are needed. One that takes a list of datestamps in order to disable specific dates, and one like that takes a list of days of the week in order to disable all weekends, for example.
To @AaronDewes's point, in the list of dates example the list could get quite long and it would be up to implementors to manually maintain and update the list periodically, but from an internationalization perspective it would be the most flexible, and certainly an improvement from the current scenario where disabling specific dates is not at all possible. |
It appears to be pretty common to have some kind of feature to disable the selection of a certain set of dates in a
<input type=date>
. Currently, we only havemin
andmax
to play with.Use-cases:
The currently existing workarounds:
Proposal:
The text was updated successfully, but these errors were encountered: