• Resolved IT Hertz

    (@it-hertz)


    CF7 validator is only throwing errors for the currently selected tab.

    For example, there are 5 tabs. Tabs 1, 3 and 4 have required but empty fields, while tabs 2 and 5 are filled correctly by the user. The user is currently in tab 1 when submitting the form. The validator shows error messages in tab 1, but when the user visits tabs 3 and 4, there are no errors.
    If the user switches to tab 3, for example, then submits again, tab 1 now shows no errors, only tab 3 does.

    The invalid fields/tabs are allowed to go through on submit, as the success/thanks message is shown.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jules Colle

    (@jules-colle)

    Hi @it-hertz,

    This is by design. Hidden fields will never cause validation errors. If you want to create a form with multiple steps, I recommend you to use the multistep function available in conditional fields pro https://conditional-fields-cf7.bdwm.be/multistep/

    Thread Starter IT Hertz

    (@it-hertz)

    Well, I was talking about tabs, not multi-step. I need tabs, as you have posted on this page: Extra: tabs

    The form in question collects data from multiple tabs, as it allows multiple persons to be registered at once (students in a small dance school). Hence, I want to use tabs. I have done it with simple hidden groups, where the groups repeat according to the number of dancers the applicant has selected. That method works fine, but the form looks nicer with tabs, since duplicating groups adds length to the form, whereas tabs don’t.

    The reason I ask about validation only on focused tabs is because the plugin Smart Grid-Layout Design does run all tabs through the validator, including hidden. This is the logical approach, since there’s no reason to allow any invalid tab fields to be passed on Submit.

    For example, if someone either doesn’t fill in a required field or enters an invalid email or phone number in a given tab, why would we want that invalid data to be sent with the form?

    Unfortunately, his Smart Grid plugin doesn’t play nice with your plugin, so I’ve had to resort to creating my form with vanilla CF7.
    I can probably manage to mod either plugin to do what I want, but I can’t spend that kind of time on it, I have to get the website built. Besides, my mods would get wiped on updates anyway. Not interested in that cat-and-mouse game.

    Naturally, I don’t want to clear_on_hide tab fields/groups, which would get rid of invalid data, but it would also defeat the purpose of using tabs in the first place, which is to collect data from all the tabs, not just the focused one.

    Is this a Pro version thing as well? Do Pro users get all their tabs validated?
    If not, then I’m afraid I fail to understand your reasoning for not validating all tabs.

    Plugin Author Jules Colle

    (@jules-colle)

    In my opinion, triggering a validation error on a field that isn’t visible, seems like very bad practice. I have played with this idea quite a bit, but I still find this scenario a bit weird:

    say that your user has made a mistake in one tab, that is currently not visible. He would now need to click trough all tabs again, to find out where the error occurred. This could be solved by having a built-in tab system, that would highlight the tab-button indicating that there is an error under that tab. However, this feature does not exist in conditional fields or conditional fields pro. The closest possible thing to what you are looking for is multistep. Here, each completed step will be validated before you can move to the next one. With a bit of javascript code, you can allow your users to skip steps. https://conditional-fields-cf7.bdwm.be/multistep-example-move-to-specific-step-programatically/

    Also note that the article you are referring to is not published on the conditional fields website, but on my personal website, just as an example of what can be done with contact form 7. It’s unrelated to conditional fields (except for the reference in the end) and I’m not advocating to create tabs like this. Please just view it as a quick and dirty code example of how CF7 can be extended.

    Lastly, if you want me to check if I can improve your form, please use the form tester and send me the updated link, so I can have a look: https://conditional-fields-cf7.bdwm.be/form-tester/

    EDIT: since you mention that you are using the tabs to register multiple people, you might also be interested in the repeater function available in pro: https://conditional-fields-cf7.bdwm.be/repeater/

    • This reply was modified 3 years, 11 months ago by Jules Colle.
    Thread Starter IT Hertz

    (@it-hertz)

    This could be solved by having a built-in tab system, that would highlight the tab-button indicating that there is an error under that tab.

    Yep, that’s how Smart Grid does it, prompts the user by highlighting the tab containing the error.

    He also allows for adding/removing tabs, which eliminates validation errors for empty, undesired tabs.

    I understand how not validating intentionally empty tabs with required fields could be a problem, since the user didn’t want to fill them out in the first place.
    Basically, I was hoping to do with tabs in your plugin what I was doing with the toggle in your plugin that adds sections per user spec. I thought perhaps with a little extra code I could use a radio, whereby the user selects the number of dancers to be registered and that number of tabs appears and then all tabs would be validated.

    It’s most unfortunate that his plugin isn’t compatible with yours. He even shows your Conditional fields tab in his CF7 in some of his video tutorials of his own plugin! So, I thought surely it must work or else why would he be using it. I posted in his support forum about this, and other people have said it isn’t working for them, either, but no response from him yet.

    Oh well… I need conditionals for this form, so the toggled section approach will have to do. This dance school is poor. They even had to get rid of their studio telephone! I’m their pro bono webmaster because a relative is involved. They aren’t interested in paying for their website goodies, and I won’t have need of registration forms of this complexity after I’m done with their website, so purchasing extras is not an option at this time, sorry.

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

The topic ‘validation only on selected tab’ is closed to new replies.