Class for Contact Form 7 Optional field label

This topic has 5 replies, 2 voices, and was last updated 2 years, 6 months ago ago by ianbarker24

  • Avatar: ianbarker24
    ianbarker24
    Participant
    October 4, 2021 at 10:42

    Hi

    I can see that the label class for a required field is class=”required-item”, but what is the class for an optional field please? I tried class=”optional-item” but that didn’t work.

    Many thanks
    Ian Barker

    4 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    October 4, 2021 at 15:59

    Hello,

    If the field is optional it does not have a special class. But you can add any custom class for any field you use using class attribute, check here for example https://contactform7.com/text-fields/

    Regards

    Avatar: ianbarker24
    ianbarker24
    Participant
    October 4, 2021 at 16:12

    Hi Olga,

    The problem I have is that I removed the class statement for an attachment field in the contact form however it is still showing an asterix at the end of the title even though the field is not required, i.e. the form will submit with or without an attachment.

    So, I’m trying to remove the asterix at the end of the title of the attachment field.

    The form entry I have is,

    [file your-attachment filetypes:gif|png|jpg limit:2mb]

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    October 5, 2021 at 10:13

    Hello,

    Because you added custom code to show it for all the labels https://prnt.sc/1uvc27c
    Change it to

    .wpcf7-form label.required-item:after {
        content: "*";
        color: #E95D2A;
    }

    Regards

    Avatar: ianbarker24
    ianbarker24
    Participant
    October 5, 2021 at 10:27

    Fantastic, many thanks Olga

    All good now.

    Cheers
    Ian

  • Viewing 5 results - 1 through 5 (of 5 total)

The issue related to '‘Class for Contact Form 7 Optional field label’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.