Forums

Field Conditionally Required

tshirley 17 Jun, 2019
Hi,

I am sure this question has been asked and answered before, but I can't find a reference to it.

How can I make a field required depending on the value of some variable? Specifically, this relates to where a person filling a form is under 18 - in this case the parent's email address is required for consent, but if they are over 18 then it is not.

Cheers

Tim
healyhatman 18 Jun, 2019
Field events, disable validation
tshirley 18 Jun, 2019
Thank you..

Yes I can see it is possible but I am not certain how to achieve it. The person states their date of birth on the form, and I want the parental consent email field to be mandatory if the date is less than 18 years before today, and empty (or at least not mandatory) if the date is more than 18 years from today. To do this I have to use javascript but i have trouble with date handling.

Is there any example of a js script for this?
healyhatman 18 Jun, 2019
moments.js is loaded as part of CF so look that up makes it easier
This topic is locked and no more replies can be posted.