D
D
Dmitry Klimantovich2020-06-24 13:16:42
Bootstrap
Dmitry Klimantovich, 2020-06-24 13:16:42

How to interrupt Contact Form 7 validation in order to do it using bootstrap?

On my form to send a request to a third-party api, I implemented validation through Bootstrap.

var forms = document.getElementsByClassName('needs-validation');
      var forms = Array.prototype.filter.call( forms, function(form) {
      	console.log( forms );
      	form.addEventListener('submit', function(event) {	    		
        var error = 0;
        var this_form = $(this);
        var this_form_message = this_form.find('.wpcf7-response-output');
        this_form_message.empty();
      		if (form.checkValidity() === false) {
      			event.preventDefault();
      			event.stopPropagation();
      			error = 1;
      		}
      		form.classList.add('was-validated');
      		if ( error != 1 && !$(this).data( 'fl_form_sended' ) ) {
      			event.preventDefault();
      			error == 0 && this_form_message.empty().removeClass('show');
      			//формируем данные на отправку
          var form_data = this_form.serialize();
          //обрабатываем форму
          $.ajax({

After successful validation, the request is sent via the API and receives a response. This response is substituted into the second form, in which the visitor needs to fill in the name, number and mail and click submit. But the second form is made through contact form 7 (and I would like to leave it that way) and the validation goes through Contact form 7. How to suspend the validation and submission of Contact Form 7 until Bootstrap validation passes?
5ef32774d06ba335263542.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question