validation with two elements, one non-empty

MILORD65

Member
Hello,

I have two ?l?ments on the same form and I want them to be validated only if at least one of them or both is not empty.
I think it is necessary to use the php validation plugin but I don't find the code to put in condition and in php code.
Thank for your help

JP
 
Well, are you talking about using this as the "condition" (which determines if the validation itself should be run), or as the validation itself?

If it's the validation itself, then don't put it in the Condition, put it in the PHP code box.

-- hugh
 
Thank you for your reply.
The problem is that if I put this code in the php code box, the validation fails for both items. If I put it in the condition box nothing happens. What I am trying to do is a validation if at least one of the two elements is filled or both.
Validation must fail if both elements (A and B) are empty.
I think this is the same as in the post: http://www.fabrikar.com/forums/index.php?threads/validation-with-condition-or.47055/#post-244942
I had thought of using the notempty plugin but the post that I found on the forum advises rather the plugin PHP validation.

JP
 
Thank for your reply.
By "the validation fails for both items", I mean that the text "validation failed" appears in red under the two elements and the text "Some parts of your form have not been filled correctly" on top of the form.
 
To try to better explain my problem:
If in the php validation plugin I put only in PHP code for my two elements A and B:
PHP:
return $data != '';
the validation is done systematically but separately and the message "Some parts of your form have not been properly filled in" is displayed if one of the elements is empty.
If in addition I put in "condition" of the php validation pluginfor both elements:
PHP:
return !(empty($formModel->formData['mytable ___ elementA']) && empty($formModel->formData['mytable ___ elementB']));
registration does not fail and no message "Some parts of your form have not been properly filled in" if both elements are empty.

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

Thank you.

Members online

Back
Top