• Resolved Ravi Makwana

    (@ravimakwana)


    Hello

    Is there any way to submit the form when 25 fields filled.
    I have around 50+ fields there in my form and submit at least 25 required to fill otherwise give an error message: “You must submit at least 25 fields”.

    Is there any event or filter before submitting the form? So I can check whether 25 fields filled or not.

    Thank you in advance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I’d tackle this via jQuery. Check for fields with content & count them.

    Thread Starter Ravi Makwana

    (@ravimakwana)

    Hello Neil,

    Thank you for the answer.

    Can you please give me an example related to this issue?

    Thank you.

    Thread Starter Ravi Makwana

    (@ravimakwana)

    How can we prevent the submission of the form when the fields are not reached 25?

    Please let me explain in detail, So I can implement in the website.

    Thank you.

    Thread Starter Ravi Makwana

    (@ravimakwana)

    document.addEventListener('wpcf7submit', function (event) {
            var inputs = event.detail.inputs;
            console.log(event);
            for (var i = 6; i < inputs.length; i++) {
                if (inputs[i].value != "") {
                    counter++;
                }
            }
            console.log(counter);
            if (counter < 25) {
                total_remain = 25 - counter;
                alert("You must submit at least 25 votes. " + (total_remain) + " remain");            
            }
            counter = 0;
        }, false);

    I have created the code but when we submit the form, It counts well and display the alert message but after click on the alert OK button, the form is submitted.

    Is there any way to prevent submission of the form using jQuery?

    Is there any way to prevent submission of the form using jQuery?

    A rough & ready option would be to change Submit button CSS to display: none;.

    There are possibly also better options available in the CF7 Docs.

    Thread Starter Ravi Makwana

    (@ravimakwana)

    This is not my answer. Ok no problem. I will do my self.
    Thank you

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to submit form at least 25 fields out of 50 or more fields’ is closed to new replies.