Custom Form Date validation dynamic keyword


(Tim Davison) #1

Matrix Version: v5.1

Does anyone know if there is a way to add min/max validation for custom form date fields that is dynamic?

E.g. We have a form where user has to say when an incident happened, but we have a requirement that they cannot enter a date in the future. Default (and only, it seems) way dates are laid out is as 3 (or 5 with time) dropdowns. We can limit manually but this is a fixed time. Ideally we’d like to validate the date is always less than current date/time.


(Peter McLeod) #2

Hi

Just an idea - haven’t really tested it…

2 text inputs rather than a datetime.

The first is one to reference in a validation condition in the actual input field. This can be removed from form page contents.

It’s default value could be:
%globals_date_Y%-%globals_date_m%-%globals_date_d%

The second would be the actual date input (probably with JS date selector of some sort).

This would have a Value Comparison condition that Must Be Less Than or Equal To the value of first field.

Could probably add an additional condition to enforce a valid date input via the JS input as well.

This wouldn’t be a true date value though, so depending on how you are using the response it may not be suitable.

Thanks
Peter