Summary
This script runs when target date questions of a study are saved on any form. In this case, the script is expecting a format of 2 digits, a hyphen, 3 upper or lower case letters, another hyphen, and then a 4 digit year 2000 to 2099. If that format is not found, it fires an alert to the user to indicate that the response should be modified. This alert is required so the user cannot proceed without making the correction. If this is an optional format, the correction should be set to “optional”.
Script
<script scriptId="validateDate"> <body> <s:alert> <s:expression> <s:regex pattern="[0-3][0-9]-[A-Za-z]{3}-[2][0][0-9][0-9]"> <s:stringPath path=":value"/> </s:regex> </s:expression> <s:correction> <s:string value="required"/> </s:correction> <s:text> <s:string value="Value entered must be a date (dd-MMM-yyyy); must be a 4 digit year between 2000 and 2099. Please correct."/> </s:text> </s:alert> </body> <target typeId="questions" action="update" when="preprocess" shouldReconcile='true'/> <target typeId="go" action="update" when="preprocess" shouldReconcile='true'/> <target typeId="here" action="update" when="preprocess" shouldReconcile='true'/> </script>
Need more help?
Please visit the Fountayn Contact Information page.