- 06 Mar 2026
- Print
- DarkLight
- PDF
Exclude Weekends or Holidays from Calendar Widget in Forms
- Updated 06 Mar 2026
- Print
- DarkLight
- PDF
You can use a calendar widget on a form 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:
Ensure that your calendar field has an export label, such as "date".
Select Edit Scripts / Styles.
In the Custom Scripts tab, paste the following:
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]; }});Select Save.
Test the form to ensure that the calendar days are being disabled as desired.
Example

You only need to reference your export key at the beginning, where it says form.getQuestion(.
All other references to date should remain unchanged:
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];
}});