From 50840a675f018d7b9296f99b760f5cbff6356a68 Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 30 Mar 2020 12:34:35 +1100 Subject: [PATCH] Check for data changes Check for data changes before triggering validation e.g. future date entered, then return to form after that date - only trigger validation if data on the form have changed. --- DateValidationActionTags.php | 4 +++- README.md | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DateValidationActionTags.php b/DateValidationActionTags.php index 75e27f4..8ec6258 100644 --- a/DateValidationActionTags.php +++ b/DateValidationActionTags.php @@ -106,7 +106,9 @@ protected function includeJS($taggedFields) { default: var min = '', max = ''; } //console.log('min='+min+' max='+max); - redcap_validate(ob, min, max, 'soft_typed', format, 1); + if (dataEntryFormValuesChanged) { + redcap_validate(ob, min, max, 'soft_typed', format, 1); + } }; var taggedFields = JSON.parse(''); diff --git a/README.md b/README.md index b93c3e2..244d591 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Action tags to validate date and datetime field entries: - If more than one of these tags is applied to a field only the first will be used. - You may still specify min/max literal values. The action tag check is applied after the range check. - The action tag validation check is a soft check similar to existing range checks (i.e. a warning is displayed but the value is permitted). +- @FUTURE/@NOTPAST: when you enter a future date/time and then after that time return to the form, the validation check will be triggered only after data on the form has changed. ![Validate](./datevaltags-check.png)