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.

Making at least one of two fields mandatory

  1. In one of my contact forms I have a field for telephone number and a field for email address. I don't want to force my visitors to enter both fields, but I would like at least one of them entered before the form can be submitted.

    Is there a way of making 'at least one' of a group of fields mandatory?

    Thanks.

    Posted 12 years ago on Saturday May 14, 2011 | Permalink
  2. travishines
    Member

    I have the exact same question. Is there a way to apply conditional logic to make at least one of any X fields required?

    Posted 12 years ago on Wednesday May 25, 2011 | Permalink
  3. There is no built in way to make one or the other required. A field is either required, or it is not required.

    You can, however, write your own custom validation using the gform_validation hook. So you could do this as a customization. Documentation for the gform_validation hook can be found here:

    http://www.gravityhelp.com/documentation/page/Gform_validation

    A tutorial on how to use the gform_validation hook to write custom validation can be found here:

    http://www.gravityhelp.com/documentation/page/Using_the_Gravity_Forms_%22gform_valiation%22_Hook

    Posted 12 years ago on Wednesday May 25, 2011 | Permalink
  4. travishines
    Member

    Thanks for the quick reply Carl. As a work-around, I was able to use a multiple-choice field with two options, both of which conditionally show a new field. Making that multiple-choice field required, technically makes either of the two conditional fields below it required.

    Not the most ideal solution, but in an either or instance, it does the trick.

    I, like many others, still vote for the ability to group fields (beyond sections), and apply conditional requirement logic to the fields in groups :)

    Posted 12 years ago on Wednesday May 25, 2011 | Permalink