This REDCap external module is deprecated because REDCap now has functionality to mimic it. Vanderbilt University Medical Center (VUMC) added the ability to use piping and/or today/now for the min/max ranges for date fields. In the example below, the date entered has to be between their visit date and today’s date:
To prevent a future date, you would use 'today ‘ (without quotes) for the maximum. To prevent a past date, you would use ’today’ (without quotes) for the minimum.
This REDCap module adds actions tags @PREVENT-FUTUREDATE and @PREVENT-PASTDATE that can be applied to date fields - i.e., a text field with date validation applied - to disallow entry of dates in the future or past, respectively. The tags are mutually exclusive, applying both tags will not result in any date restrictions. To enforce today's date use the @TODAY action tag instead.
- REDCap >= 14.0.2
- PHP >= 7.4
- Clone this repo into to
<redcap-root>/modules/prevent_past_or_future_dates_v0.0.0. - Go to Control Center > Manage External Modules and enable Prevent Past or Future Dates.
- For each project you want to use this module, go to the project home page, click on Manage External Modules link, and then enable Prevent Past or Future Dates for that project.
| Applied Tags | Dates available in Datepicker | |
|---|---|---|
| Scenario 1 | @PREVENT-FUTUREDATE | past - today |
| Scenario 2 | @PREVENT-PASTDATE | today - future |
| Scenario 3 NOT SUPPORTED | @PREVENT-FUTUREDATE && @PREVENT-PASTDATE | N/A - supplying both tags will not apply any date restrictions use @TODAY instead |
The action tags will only apply to empty fields; if data already exists in a field when the form is loaded the action tag will not apply to that field. This is to prevent annoyances when revisiting forms.
This module handles date fields and datetime fields slightly differently:
- If a datetime field fails validation and the datetimepicker is opened and loses focus, the input will be updated automatically to the closest valid date.
- If a date field fails validation and the datepicker is opened and loses focus, the input will not be updated automatically. A validation alert will display and the value will need to be updated manually.

