WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] cannot validate required custom fields (5 posts)

  1. George Vrettos
    Member
    Posted 1 year ago #

    I have created a barebone contact form through the admin panel.
    But there are cases that I create and add to the form my own custom text fields (through jQuery) based on whether the user is logged in in my website or not.

    The custom fields are generated correctly and their values posted fine when I click on the submit button. I have also added the class "wpcf7-validates-as-required" which is supposed to enforce them to be validated with some kind of value before the message is sent. The other fields which I generated through the admin panel do not have a problem with that and are correctly validated but my custom fields are posted even with null values...

    Any idea?

    P.S.
    Contact Form 7, version 3.2.1

    http://wordpress.org/extend/plugins/contact-form-7/

  2. George Vrettos
    Member
    Posted 1 year ago #

    The validation is done for all fields with the following plugin but I prefer the built in validation function visually, so my problem still exists. :)
    http://wordpress.org/extend/plugins/jquery-validation-for-contact-form-7/

  3. George Vrettos
    Member
    Posted 1 year ago #

    Well, I couldn't get why the validation script couldn't catch my custom field so I resolved it the "opposite" thinking way. That is, I created the filed normally through admin panel and from my source code I used jQuery in order to hide it - instead of creating as I was trying to do.

    That way it finally worked!

    Although there was no response, thanks everyone who got in the trouble to bother with my problem. :)

  4. George Vrettos
    Member
    Posted 1 year ago #

    Just forgot to mark it as resolved. :)

  5. fcvolunteer
    Member
    Posted 1 year ago #

    @George Vrettos I'm trying to get the validation to ignore required hidden fields which only become visible depending on what the visitor selects from the radio button options. I can't get it to ignore them and then submit. I've used jquery to hide the fields but I'm pretty sure my problem is in the php. Did you have that problem? Do you have any suggestions?

    My test form is here/

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic