How do I restrict past and today's date from a calendar? | XM Community
Question

How do I restrict past and today's date from a calendar?

  • 23 April 2019
  • 6 replies
  • 274 views

Hi XM Community:

Is it possible to restrict today's date from showing in a calendar and only show specific dates future in the future? We are using flatpickr.js for the inline calendar.

We created a registration form for the live-training sessions that we host weekly using Research Core in Qualtrics. In the form, individuals select the training session and then proceed to pick the date and time they want to attend. We use Display Logic to determine which calendar will show depending on the training session selected because the sessions are offered on different days of the week. Currently, each calendar is set up to show today's date and specific dates when a training session is available; i.e. menu training is available on Mondays; systems training is available on Tuesdays, etc.

We pull the registrations in the morning and then email the registrants with the information to join the session. From time to time, there are individuals that register the day of the training, sometimes thirty minutes before the start of the session, so we want to restrict today's date from showing up.

Here is the code that is currently in one of the calendars; the code is identical for the others with the exception of different dates.

!

What do I need to add/update in the code to restrict the date for today from showing up?

!

6 replies

Badge +1
To restrict today's date, get the date for today and add one day to it. Then make that your minimum date.
The intent is to restrict the "current day" when an individual accesses the registration form; in this case, "today's date" will change every day and I prefer not to edit the form daily.

Let me know if this makes sense; I should have posted the question differently in my original post.
> @aszuster said:
> The intent is to restrict the "current day" when an individual accesses the registration form; in this case, "today's date" will change every day and I prefer not to edit the form daily.
>
> Let me know if this makes sense; I should have posted the question differently in my original post.

You can put this at minDate - `minDate : "${date://CurrentDate/DS}",`
@shashi Hi Shashi:

Thank you but this does not appear to work either. I changed the minDate as you suggested, however today's date is still visible/available in the calendar. Did I enter the code incorrectly? Is it possible to add a "+1" or other codes to make this work?

See attached and let me know.

!

!
Badge +1
var SomeDate = new Date(); // get today's date
SomeDate.setDate(TodaysDate.getDate() + 1); // add 1 day to it
use SomeDate as the mindate value
Badge +1
oops, second line has typo. use instead:
SomeDate.setDate(SomeDate.getDate() + 1); // add 1 day to it

Leave a Reply