Custom Rule - Validaion

SwingeyP 28 Jan, 2021
I am trying to achieve this
If a text field A is <> 0 or text field B <> 0 then
text area is mandatory
else text area is optional.
I can't see a way of conditionally setting a field as required so I have a custom rule in the validation which I think has to be JavaScript?
It's been a log time since I did any JS so please forgive my ignorance.

This doesn't work😟

if if (document.forms['TestNotProcessedAppropriately'].value !=0){
document.getElementById("IncidentDetails").required = true;
}
if if (document.forms['NumberOfIncidentsReported'].value !=0){
document.getElementById("IncidentDetails").required = true;
}

What is the correct syntax for doing this with Chronoforms please?
Max_admin 03 Feb, 2021
Answer
you can do this with field events behavior, in your target field, make it required and disabled, then in the events behavior add the following rule:
field A <> 0
field B <> 0
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.

VPS & Email Hosting 20% discount
hostinger