Tip: You can do this in modern surveys and the script is now available! For more information, see How do I ensure a Date question cannot be set to a future date? (Modern Surveys).
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 document you can add a script that will not allow the user to enter a date in the future. If the user tries to enter a date in the future an error will be displayed.
Detailed Steps
- Create a Date question.
- Copy the script below into Notepad or any other text editor (e.g. Notepad++, Textpad).
- Replace DATE with the name of the Date question.
- Insert the completed script into the Script section of the Date question by doing the following:
- Select the Date question in the Questionnaire Tree.
- In the Scripting section of the question, click Edit Scripts.
- Paste the script into the On Validate tab.
- Click Save.
- Click Validate and test your survey.
Script
/*
Script Name: How do I ensure a Date question cannot be set to a future date?
To ensure your script works as expected, always copy the original script from the script library found in the
support portal. Failure to use the most up to date script from the script library may cause unexpected results.
*/
if(!IsATR){
if(DateTime.Now<DATE.DateTimeValue){
NewError("Please do not enter a date in the future.");
}
}
Note: The date and time used by the script is in PST.
More Information
Read this WebHelp article to learn more about the Date question.
Comments
0 comments
Article is closed for comments.