validation with condition OR

enzo2016

Member
Hi,
a form includes two elements with validation notempty. I would need that at least one of them is not empty. So if one (or both of them) is full then is ok, but if both of them are empty, then the validation should avoid that.
I wrote the following code into the condition box for both of them:

Code:
return '{table___element}' == 2 || '{table___element}' == 1;

I tested it, but if I don't fill both of elements, then no validation is shown. How can I solve?

Thanks,
Enzo
 
I would just do it with a PHP validation on both elements, that does ...

return !(empty($formModel->formData['table___element1'] && empty($formModel->formData['table___element2']);

-- hugh
 
Thanks for the code. If I don't fill both of the two elements, then the following error appears: 0 syntax error, unexpected ';'

By deleting the ; (semicolon) from the code, it appears: 0 syntax error, unexpected end of file.


-- Enzo
 
Ooops, typo ...

Code:
return !(empty($formModel->formData['table___element1']) && empty($formModel->formData['table___element2']));

That's the problem with writing code of the top of one's head with lots of brackets, easy to lose count.

-- hugh
 
Thanks. Both of the elements have a php validation. If one of these elements has for example also a isemail validation, how could this further validation be activated only if this element was filled?
Example: the form includes 'element 1' and 'element 2' with this php validation. If the user fills only element 1, but element 2 has also an isemail validation. How could this validation (of element 2) be activated only if element 2 is filled?

Thanks,

Enzo
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top