Excluding closed days from booking candidates | flatpickr

プログラミング・Web開発カテゴリを表すパンダのイラスト Programming / Web Development

About this article
This article is created using an automated generation workflow leveraging generative AI. Operations, observations, and limitations were organized by referencing official documentation and fixed code from learning materials.

Verification status: Partial cross-checking with official information and implementation. Real-browser behavior for the fixed version has not been verified.

If the office is closed on weekends, you can exclude weekends from the reservation form candidates. Select Friday and Saturday in order to check the differences in the input fields.

Open live demo

Terminology to know first

  • Date pickeris an input component used to select a date from a calendar.

  • Disabled dateis a date that cannot be selected.

Thinking with a branching flowchart

Check for "weekends" using the diamond shape. The next step changes depending on the result.

flowchart TD
    A["予約日を選ぶ"] --> B{"土日?"}
    B -- "はい" --> C["その日を選択不可にする"]
    B -- "いいえ" --> D["日付を受け付ける"]

Operating the live demo

Click Friday and Saturday on the calendar. Verify the days where the input field updates.

How to interpret the results

Weekends cannot be selected.

Holiday ranges vary by region and operation. If weekends alone are not sufficient to determine availability, add national holidays and temporary closures to the reception conditions.

Key points of the code

Specify a function that returns weekends for disable.

The implementation can be viewed in the implementation code on the demo screen.

When using it in a work environment

Validate non-business days on the reservation acceptance side as well. The client calendar serves to assist with input.

Select Friday, Saturday, Sunday, and Monday in that order.

This tutorial does not require the input date string in advance. Clicking the execute button generates the calendar and input field. Select Friday on the displayed calendar and verify whether the date is reflected in the input field and result field. Next, attempt to select Saturday and Sunday. Expect them to be unselectable because they fall on non-business days. Finally, select Monday and compare whether it can be updated to an available date.

Date for validationDay of weekExpected disable determination
2026-12-04Frifalse
2026-12-05Sattrue
2026-12-06Suntrue
2026-12-07Monfalse

Using the same day-of-week judgment function as the implementation with the date above, we executed it in Node.js and verified the values in the table. We navigate to the target month on the calendar and compare whether selection is actually possible. Because the display color of disabled dates and the behavior during interaction depend on the theme and device, reference tests alone do not guarantee browser display.

Meaning of true returned by disable

flatpickr's disable option allows you to set dates, periods, and judgment functions. In this code, a single function is passed, and it returns true if getDay() of the argument date is 0 or 6. JavaScript's getDay represents Sunday as 0 and Saturday as 6. This value differs from getDate, which indicates the day of the month. The true value in the judgment does not mean that the date can be selected, but rather that the day is disabled. Reversing the condition may prevent weekdays from being selectable.

In the tutorial, inline:true displays the calendar, and onChange outputs the selected date string to the results field. The selected date is not used for actual reservation acceptance or transmission to external services. The design applies the day-of-week judgment even when switching years and months. It is convenient because humans do not need to manually list the positions of weekends for each month.

Holidays and reservable dates are not the same

In actual front-desk operations, there are public holidays, year-end and New Year holidays, and temporary closures in addition to weekends. Even on weekdays, requests may not be accepted if reservations are fully booked. This demo does not include public holidays, temporary closure dates, reservation counts, or past-date restrictions. Therefore, the design does not treat being a weekday as the sole condition for confirming a reservation. It also accounts for business days varying by organization.

In operation, the list of holidays and receivable periods should be managed on the server side and reflected in the form. Define the time standards to be handled, such as using the user device's time zone for displayed dates and the service side's time zone for application deadlines. Because the current getDay evaluates dates based on local time, be careful of date shifts when directly passing UTC timestamps. It is good practice to separate the design depending on whether the reservation target is just a date or includes specific times.

Verification before practical implementation

Check not only visual cues, such as unselectable dates turning gray, but also whether keyboard navigation and screen readers convey that a date cannot be selected. Providing the reason for closures in text helps users choose another date easily. If regular business days are also unselectable, first check whether the conditions of the judgment function are reversed and whether CSS and modules are loaded correctly.

Browser-side constraints are merely input aids, and the server side must always validate the values submitted by the user. Reconfirm closures and available slots when confirming reservations, and determine how to handle cases where conditions change due to simultaneous bookings. The public demo does not require entering personal or reservation information. Comparisons are made using fictitious schedules without connecting to actual reservation services.

Verification scope

The specified tutorial version is flatpickr 4.6.13. The same getDay judgment as the implementation was executed for reference on Node.js 22.16.0. 2026-12-04 (Fri) false, 05 (Sat) true, 06 (Sun) true, 07 (Mon) false. Asserted the first three items. The flatpickr core and calendar operations were not executed. CDN acquisition, license pinned-version verification, and actual rendering must be checked separately.

Reference materials

GitHub sample

Implementation and experimental procedure

Document information

Article title
Excluding closed days from booking candidates | flatpickr
Published
Updated
Source
https://papanda925.com/?p=19100&lang=en

License: Text and original figures for which this site holds the relevant rights are available under CC BY 4.0 , unless otherwise noted. This article may include content created or edited with generative AI. If code has a separate license notice or a linked GitHub repository license, that license takes precedence for the code. Quotations, third-party materials, images, and trademarks are excluded from this license. Usage policy

Copied title and URL