Title: Conditional field problem
Last modified: February 24, 2023

---

# Conditional field problem

 *  Resolved [kingsdavid](https://wordpress.org/support/users/kingsdavid/)
 * (@kingsdavid)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/)
 * In my form, depending on the age of the user, the email field is mandatory or
   optional.
   So I created a condition to display the mandatory or optional fields
   depending on the age.
 * _[checkbox eleve use\_label\_element exclusive “Mineur ” “Majeur”]_
 * _[group elevemineur]
    Email : [email email] [/group]
 * _[group elevemajeur]
    Email* : [email* email] [/group]
 * The display works correctly but the code does not work, the email field is considered
   optional regardless of the age chosen (minor or adult).
 * The asterisk (_) of [email_ email] is not taken into account.
 * Of course, I can create two different names email_minor and email_major but I
   need to have a single item for display in a single column of a table afterwards.
 * Do you have an idea to solve this problem?

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

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16504561)
 * Where can we see the website in question?
 *  Thread Starter [kingsdavid](https://wordpress.org/support/users/kingsdavid/)
 * (@kingsdavid)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16505058)
 * Hello, here is the website page. You’ll see that the display works correctly 
   when you choose Mineur or Majeur but the asterisk (*_) _in_ [email* email]_ is
   not taken into account, the message is still sent.
 * [https://www.embba.fr/test2/](https://www.embba.fr/test2/)
 *  [AW](https://wordpress.org/support/users/geykgn/)
 * (@geykgn)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16505142)
 * Hi,
   [@kingsdavid](https://wordpress.org/support/users/kingsdavid/) you have two
   fields with the same name. Isn’t it so that the first one is taken for verification,
   which is optional in your case? You change the order of the fields and you check.
 *  Thread Starter [kingsdavid](https://wordpress.org/support/users/kingsdavid/)
 * (@kingsdavid)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16505174)
 * Yes I know. 
   I need the fields to have the same name because the mail will then
   need to appear in a single column of a tablesome or flamengo table. If I change
   the order, it’s the same result. The form is sent.If I put two different names
   email1 email2, tablesome or flamengo will display them in two separate columns.
   Since I have many more fields than Email, this will make a very long and unreadable
   table
    -  This reply was modified 3 years, 3 months ago by [kingsdavid](https://wordpress.org/support/users/kingsdavid/).
    -  This reply was modified 3 years, 3 months ago by [kingsdavid](https://wordpress.org/support/users/kingsdavid/).
 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16506405)
 * What other plugins and theme do you use on the site?
 *  Thread Starter [kingsdavid](https://wordpress.org/support/users/kingsdavid/)
 * (@kingsdavid)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16506768)
 * Here the entire plugin list :
   – Conditional Fields for Contact Form 7– Contact
   Form 7– Disable Comments RB– Everest Gallery Lite– Honeypot pour Contact Form
   7– MailPoet– Photo Gallery– Simple CSS– SpiceBox– TablePress– Tablesome– The 
   Events Calendar– Ultimate Social Media PLUS– Yoast SEO
 * The theme is Bravada
    -  This reply was modified 3 years, 3 months ago by [kingsdavid](https://wordpress.org/support/users/kingsdavid/).
 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16508079)
 * Try switching to the default theme, deactivating all plugins excluding Contact
   Form 7 and Yoast SEO, and clearing all cache data.
 * [Why you are advised to deactivate plugins and switch to the default theme.](https://contactform7.com/2019/12/02/why-you-are-advised-to-deactivate-plugins-and-switch-to-the-default-theme/)
 *  Thread Starter [kingsdavid](https://wordpress.org/support/users/kingsdavid/)
 * (@kingsdavid)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16508240)
 * I’ll try. Of course I also have to exclude _Conditional Fields for Contact Form
   7_ plugin, otherwise I won’t do the test to know if the condition works, is that
   right?
 * If you ask me to test without plugins and with the default theme, does that mean
   that normally the script should work?
 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16508421)
 * > I also have to exclude Conditional Fields for Contact Form 7 plugin
 * No, deactivate that plugin.
 *  Thread Starter [kingsdavid](https://wordpress.org/support/users/kingsdavid/)
 * (@kingsdavid)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16511293)
 * I don’t understand: if I deactivate this plugin (Conditional Fields for Contact
   Form 7), the code no longer makes sense. There are no more group, no more conditions,
   there are two fields left with the same name, with the only difference being 
   one optional and the other mandatory .
   I tried anyway with the default theme 
   and with the current theme, deactivating all plugin excluding Contact Form 7 
   and Yoast SEO, and clearing all cache data → the result is that both are considered
   mandatory, whatever the order of the fields.
 * _[checkbox eleve use\_label\_element exclusive “Mineur ” “Majeur”]_
 * [group elevemineur]
    Email : [email email] [/group]
 * [group elevemajeur]
    Email* : [email* email] [/group]
 *  [AW](https://wordpress.org/support/users/geykgn/)
 * (@geykgn)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16511598)
 * Hi,
   Wouldn’t a more appropriate approach be to define one non-mandatory email
   field and use a custom validator for that field ([Custom validation](https://contactform7.com/2015/03/28/custom-validation/))?
   The group can be used to control the label for this field 😉.Something like:
 *     ```wp-block-code
       [checkbox eleve use_label_element exclusive “Mineur ” “Majeur”]
   
       <label>Email
       [group elevemajeur]*[/group] : [email email]
       </label>
       ```
   
 * PS. I don’t know the _Conditional Fields for Contact Form 7_ plugin.
 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16512104)
 * Now you understand that it is the Conditional Fields for Contact Form 7 plugin’s
   problem. Post it to [their support forum](https://wordpress.org/support/plugin/cf7-conditional-fields/)
   instead of here.
 * [Welcome to Support Forum — Please Read Before Posting](https://wordpress.org/support/topic/welcome-to-support-forum-please-read-before-posting/)
 *  Thread Starter [kingsdavid](https://wordpress.org/support/users/kingsdavid/)
 * (@kingsdavid)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16512142)
 * Ok, thanks for your help
   I will post on the forum and let you know.
    -  This reply was modified 3 years, 3 months ago by [kingsdavid](https://wordpress.org/support/users/kingsdavid/).

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

The topic ‘Conditional field problem’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 13 replies
 * 3 participants
 * Last reply from: [kingsdavid](https://wordpress.org/support/users/kingsdavid/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/conditional-field-problem-2/#post-16512142)
 * Status: resolved