PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Conditional Logic

  1. Is there a way to use conditional logic to require field "b" if field "a" is selected?

    Posted 7 years ago on Tuesday March 12, 2013 | Permalink
  2. David Peralty
    Administrator

    No, but using PHP and our gform_validation hook, you can send back an error to the user if they select a but not b. http://www.gravityhelp.com/documentation/page/Gform_validation

    Posted 7 years ago on Tuesday March 12, 2013 | Permalink
  3. You can add field B to your form and make it required. Hide it with conditional logic that says "if field A is selected, then show this field." If field A is selected, field B will show and be required. If field A is not selected, field B will never show, and will still pass validation even though it is hidden and required.

    Let me know if I missed something or overlooked an obvious shortcoming in this approach. I use a similar approach here: http://gravity.chrishajer.com/contact-us-left-and-right/

    You would not need two choices for A (as I use radio buttons here for call or email.) However, the phone and email fields are both required, and only one will even be submitted, because they are both hidden with conditional logic and only one will ever show.

    Posted 7 years ago on Thursday March 14, 2013 | Permalink