--- title: "Exclude Weekends or Holidays from Calendar Widget in Forms" slug: "exclude-weekends-or-holidays-from-calendar-widget-in-forms" updated: 2026-03-06T00:13:34Z published: 2026-03-06T00:13:34Z canonical: "knowledge.technolutions.net/exclude-weekends-or-holidays-from-calendar-widget-in-forms" --- > ## Documentation Index > Fetch the complete documentation index at: https://knowledge.technolutions.net/llms.txt > Use this file to discover all available pages before exploring further. # Exclude Weekends or Holidays from Calendar Widget in Forms You can use a [calendar widget](/v1/docs/form-palette#calendar) on a [form](/v1/docs/forms-overview) to capture a date input. You can also restrict the days available to the registrant, for example, to only non-holiday weekdays. The following code restricts the selection of weekends and holidays (a list that you can modify and maintain), and this code can be modified to restrict selection of other days of the week, too. In your form: 1. Ensure that your calendar field has an export label, such as "date". 2. Select **Edit Scripts / Styles.** 3. In the **Custom Scripts** tab, paste the following: ```javascript var holidays = ['7/4/2016', '12/25/2016']; form.getQuestion('date').find('.hasDatepicker').datepicker('option', { beforeShowDay: function(date) { var show = true; if(date.getDay() == 0 || date.getDay() == 6){show = false;} //exclude weekends for (var i = 0; i < holidays.length; i++) if (new Date(holidays[i]).toString() == date.toString()) { show = false; break; } //exclude holidays\\ return [show]; }}); ``` 4. Select **Save.** 5. Test the form to ensure that the calendar days are being disabled as desired. ## Example ![inline-512538150.png](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/inline-512538150.png) You only need to reference your export key at the beginning, where it says `form.getQuestion(`. All other references to `date` should remain unchanged: ```javascript var holidays = ['7/5/2021', '12/25/2021']; form.getQuestion('sys:field:callback').find('.hasDatepicker').datepicker('option', { beforeShowDay: function(date) {  var show = true;  if(date.getDay() == 0 || date.getDay() == 6){show = false;} //exclude weekends  for (var i = 0; i < holidays.length; i++) if (new Date(holidays[i]).toString() == date.toString()) { show = false; break; } //exclude holidays  return [show]; }}); ```