Forums

Optional validation + validation by event

jj135 18 Sep, 2017
Hi! On a form I have an optional e-mail field. Only when someone enters some text here I need it to validate the filled in e-mailaddress. So I check did not check 'Required' , but I did check the option 'Optional' on the validation tab. This works fine.

But I also have a checkbox 'Newsletter'. And when this is checked I want the e-mail 'required' to activate.

To accomplish this I check 'Disabled' on the e-mail field validation tab. And on the checkbox events tab I created an event to activate the validation on the email when it is checked. This also seems to work OK.

But because the validation is 'Disabled' on the e-mail field, the 'Optional' doesn not work anymore. So when someone does not check the newsletter box, the validation is not turned on and it is also nog validatied when some types in a value.

How do I achieve this:
- Newsletter box checked: Email field validation ON
- Newsletter box not checked: Email validation OPTIONAL (only when not empty)

Or can this not be done? Or is there an alternate way?

Kind regards,
Jip
Max_admin 22 Sep, 2017
Hi Jip,

Indeed this is how it works here, I have just tested this:
The email field has Email + Optional + Disabled validation settings enabled.
The Checkbox has 2 events, checked > Enable validation, unchecked > Disable validation

And it does just what you described.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.