skip to Main Content

I am using the contact form 7 plugin for wordpress.
I need a fake submit button i.e. a button that does the validation check on the fields after which, if everything is ok, the user will be redirected to another url otherwise he will stay on the current page and see the input errors.
All this without sending the form data.

What can I do?

Thank you

2

Answers


  1. With CF7 most of the form validation is done on the server side, so there’s no way to validate a form without actually sending the form data. This is done via AJAX. You can, however, add a DOM listener that will redirect the user after that validation succeeds: https://contactform7.com/dom-events/

    Login or Signup to reply.
  2. set the attribute "required" in input or texarea

    let form_element = document.querySelectorAll('.input-or-textarea');
    
    form_element.forEach((element) => element.setAttribute('required', true));
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search