Title: Required fields inside hidden group
Last modified: January 27, 2022

---

# Required fields inside hidden group

 *  Resolved [dependencyinjection](https://wordpress.org/support/users/dependencyinjection/)
 * (@dependencyinjection)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/required-fields-inside-hidden-group/)
 * Hi and thanks for amazing plugin!
 * I have an issue with this:
    >Required fields inside hidden groups will never 
   trigger validation errors.
 * How can I show the hidden group after let’s say clicking on the link?
 * I have a contact form, where user can select the reason of contact, and it shows
   the probable solution, and also the link ‘I still need help’. I added some simple
   jQuery to show the hidden group after click on this link, but all required fields
   inside that group became non-required (it works fine when hidden group is shown
   by condition, but not by mine js).
    As for now, I solved it using old good jQuery,
   but I’m wondering if there’s better solution?
 * my solution:
 *     ```
         $(".still-need-help_js").click(function (e) {
           e.preventDefault();
           $("div[data-id=\"still_need_help\"]").removeClass("group-visible");
           $("div[data-id=\"contactgroup\"]").addClass("group-visible");
           $('.wpcf7-form').removeAttr('novalidate');
           $('.wpcf7').find('.wpcf7-validates-as-required').attr('required', 'required');
         });
       ```
   
    -  This topic was modified 4 years, 3 months ago by [dependencyinjection](https://wordpress.org/support/users/dependencyinjection/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Jules Colle](https://wordpress.org/support/users/jules-colle/)
 * (@jules-colle)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/required-fields-inside-hidden-group/#post-15297657)
 * Hi [@dependencyinjection](https://wordpress.org/support/users/dependencyinjection/),
 * I’m interested to your form. Could you reproduce it here? [https://conditional-fields-cf7.bdwm.be/form-tester/](https://conditional-fields-cf7.bdwm.be/form-tester/)(
   You can also add the jQuery code in the form itself at the bottom. It should 
   work.)
 * The reason why I think not triggering validation on hidden groups always makes
   sense, is that the user cannot see the field where the error resides, so they
   won’t be able to correct it. If there’s a case where you do expect a hidden field
   to trigger validation a custom solution seems indeed the way to go.
 * That said, I could be missing your point, so I’m really interested in why you
   would need this solution. A concrete example would be much appreciated.
    -  This reply was modified 4 years, 3 months ago by [Jules Colle](https://wordpress.org/support/users/jules-colle/).
 *  Thread Starter [dependencyinjection](https://wordpress.org/support/users/dependencyinjection/)
 * (@dependencyinjection)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/required-fields-inside-hidden-group/#post-15297785)
 * Hi, [@jules-colle](https://wordpress.org/support/users/jules-colle/) ! Nice to
   meet you 🙂
 * It’s simplified version is here: [http://conditional-fields-cf7.bdwm.be/form-tester/?hash=1fa9bc8461cc9c27d83a3246a70c4692](http://conditional-fields-cf7.bdwm.be/form-tester/?hash=1fa9bc8461cc9c27d83a3246a70c4692)
 * Only I changed the code to show the block, as on demo it’s working a bit different
   than on my site, but you should get the point 🙂
 * Open the form -> Select Tech issue -> Tech issue 1 -> click “this didn’t help”
 *  Plugin Author [Jules Colle](https://wordpress.org/support/users/jules-colle/)
 * (@jules-colle)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/required-fields-inside-hidden-group/#post-15298128)
 * I would solve this with a checkbox: [https://conditional-fields-cf7.bdwm.be/form-tester/?hash=d858f0b443c7ab32c71ddc7766e92147](https://conditional-fields-cf7.bdwm.be/form-tester/?hash=d858f0b443c7ab32c71ddc7766e92147)
 * You can style the checkbox like a button if you want: see [https://bdwm.be/contact-form-7-toggle-buttons/](https://bdwm.be/contact-form-7-toggle-buttons/)
 * And you could hide the entire checkbox when it’s checked with some css like so:
 *     ```
       input[type="checkbox"]:checked, input[type="checkbox"]:checked+span {
           display: none;
       }
       ```
   
 * If you take this approach, make sure to add `clear_on_hide` to your groups, otherwise
   people will not be able to change their selection (uncheck the chekbox).
    [https://conditional-fields-cf7.bdwm.be/clear_on_hide/](https://conditional-fields-cf7.bdwm.be/clear_on_hide/)
 *  Thread Starter [dependencyinjection](https://wordpress.org/support/users/dependencyinjection/)
 * (@dependencyinjection)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/required-fields-inside-hidden-group/#post-15298227)
 * Smart!
    Many thanks for the solution, I’ll try it! 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Required fields inside hidden group’ is closed to new replies.

 * ![](https://ps.w.org/cf7-conditional-fields/assets/icon-256x256.png?rev=2072595)
 * [Conditional Fields for Contact Form 7](https://wordpress.org/plugins/cf7-conditional-fields/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-conditional-fields/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-conditional-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-conditional-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-conditional-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-conditional-fields/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [dependencyinjection](https://wordpress.org/support/users/dependencyinjection/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/required-fields-inside-hidden-group/#post-15298227)
 * Status: resolved