Join the Team Forms community

Updated 4 months ago

Date Range

At a glance
The community member is looking to set a date/time component that restricts the available dates to the current week. A community member provided a solution using the "Custom Disabled Dates" property in the date/time component and a JavaScript code snippet to disable all dates except the current week.

Hi, I would like to set a week range that includes the current actual date within that period in the date/time component for my staff to choose. How do I actually enable this function? With JavaScript or is there any other way?

Marked as solution

Within the Date/Time component you can restrict the available dates using the "Custom Disabled Dates" property. For example, to disable all dates except the current week you can use the steps below:

  1. Drag and drop a date/time component into your form

  2. Under the "Date" tab expand the "Custom Disabled Dates" setting and enter the following JavaScript code. Note that you may need to adapt the code below to fit your specific form.

JavaScript
disabled = moment(date).week() !== moment().week()


This will result in the following date picker where only this week's dates are selectable.

View full solution
E
1 comment

Within the Date/Time component you can restrict the available dates using the "Custom Disabled Dates" property. For example, to disable all dates except the current week you can use the steps below:

  1. Drag and drop a date/time component into your form

  2. Under the "Date" tab expand the "Custom Disabled Dates" setting and enter the following JavaScript code. Note that you may need to adapt the code below to fit your specific form.

JavaScript
disabled = moment(date).week() !== moment().week()


This will result in the following date picker where only this week's dates are selectable.