Currently, there is no option to set the maximum value for a Date question to be the current date. With the script and instructions outlined in this article, you can add a script that will not allow the user to enter a date that occurs in the future. If a participant tries to enter a future date, an error message will appear.
Detailed Steps
- In your survey, add a Page element.
- Add a Date question to the Page element.
- Open the Page element for editing and click the Scripting button.
- Copy and paste the script below into the On Complete tab.
- Replace Q_NAME with the Date question name.
- If necessary, replace "Please do not provide a future date" with the translated text.
- Click Save.
- Preview and test your survey.
Script
/*
Script Name: How do I ensure a Date question cannot be set to a future date? (Modern Surveys)
To ensure your script works as expected, always copy the original script from the Script
Library found in the Alida Help Center. Failure to use the latest script from the
script library may cause unexpected results.
*/
const date = response.getDataPoint("Q_NAME").get();
if(date.getTime() > Date.now())
{
response.setError("Q_NAME", "Please do not provide a future date.");
}
Example
Comments
0 comments
Article is closed for comments.