D
D
Dmitry Klimantovich2020-07-31 18:33:45
WordPress
Dmitry Klimantovich, 2020-07-31 18:33:45

How can I use hooks in functions.php to make Contact form 7 substitute my class to the form when checking fields??

Currently, Contact Form 7 submits a class to the form .invalidwhen trying to Submit with blank required fields. How to make hooks to substitute a class for example .was-validated?

This is how you can simply add a class to the form:

function wpcf7_form_class_attr_onvalidate( $class ) {
  $class .= ' was-validated';

  return $class;
}

But this is how it adds when the document is loaded. But how to make it added at the time of form validation, which occurs when the Submit button is pressed, and even the very form for which the button was pressed?
Do you also need to add a class to .is-invalidinputs that received an error during validation?

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