Page 1 of 1
Date Validation
Posted: 2013-07-10 15:00
by Accumike
Hi - I want to ensure that any date entered in a form is no more than 7 days ago.
I know how to ensure that the date is greater than current by using the {NOW} expression.
Does anyone know the syntax for 7 days ago? {NOW-7} and {NOW}-7 don't work.
Thanks in advance,
Michael Bullard
Re: Date Validation
Posted: 2013-07-11 15:58
by Fred
Hi Michael
You obviously need to add a "Throw Error" behavior to the form and link it to your "date" field.
Then build your condition (Advanced Tab) like this:
Code: Select all
{date} < date('Y-m-d', strtotime('-7 days'))
{date} is your input field that you select from the dropdown for expression 1
This is what the line of code should look like when you are done
Code: Select all
$customTransaction->registerConditionalTrigger("{date} < date('Y-m-d', strtotime('-7 days'))", "BEFORE", "Trigger_ThrowError", 50);
Re: Date Validation
Posted: 2013-07-12 12:09
by Accumike
Hi Fred,
Thanks for your help, this works very well. I even managed to include a dynamic date for 7 days ago in the error message, using a dummy recordset.
I have not really used the Throw Error function before - this has been a real eye opener.
Michael