1. Fabrik 3.7 is now available. This version contains critical security updates, please update as soon as possible. Please remember to backup your site before updating, we also recommend testing your updates on development sites if possible.
  2. We had to restore the site around midday (CST) on Wed 7/26 from a backup approximately 8 hours old. So a few posts in the forums were lost. You may want to check to see if you need to re-post anything.
  3. The release of Fabrik for J! 3.8 is not yet ready. Do not update your sites to J! 3.8 until this notice is removed.

validation with two elements, one non-empty

Discussion in 'Community' started by MILORD65, Sep 11, 2017.

  1. MILORD65

    MILORD65 Member

    Level: Community
    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
     
  2. MILORD65

    MILORD65 Member

    Level: Community
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     
  4. MILORD65

    MILORD65 Member

    Level: Community
    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
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    When you say "the validation fails for both items", what exactly do you mean?

    -- hugh
     
  6. MILORD65

    MILORD65 Member

    Level: Community
    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.
     
  7. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Right, but does it actually "work" in the sense that if you have one filled in, it doesn't fail?

    -- hugh
     
  8. MILORD65

    MILORD65 Member

    Level: Community
    No, if I have one filled in or both, it doesn't work.

    JPB
     

Share This Page