• Ive created a simple booking form and at the end of the form the user has the option to add an additional person. If they select yes in the dropdown menu a hidden form will appear, all the fields are required. The problem im having is if someone doesnt need an additional person adding and just fills in the standard form, the form still flags the required fields for the the hidden form.

    The easy fix is to add a value to those fields, but that means a user has to delete the text to enter their own. Has anyone come across a fix for this?

    Thanks

    https://ww.wp.xz.cn/plugins/contact-form-7/

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve had this exact issue. I created a .js file in my theme subdirectory. I didn’t want this script called on every page. This script has my jquery form logic. If a user checks a box it shows the additional form fields AND makes them required using $(id_if_input).prop(‘required’,true);

    Thread Starter Blaz8

    (@blaz8)

    Still cant seem to get it working … heres my code, where am i going wrong?

    //Hide the field initially
            $("#delegate1").hide();
    
    $('#additional').change(function() {
                    if ($('#additional').val() == "Yes") {
                            $('#delegate1').show();
    		        $("#inputiid").prop('required',true);
                    }
                    else {
                            $('#delegate1').hide();
                    }
            });
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Hidden required fields’ is closed to new replies.