How do I change the text content of a div for a comment validation error message?

if your above Javascript is working fine and you want to insert that into a page. Kindly add the following code to your functions.php. I have tested this code it’s working fine. function handle_comment_error() { ?> <script> document.getElementById(“comment-error”).innerHTML = “Please enter your comment.”; </script> <?php }add_action(‘wp_head’, ‘handle_comment_error’); Let me know if you face any issues.

Add Server Side validation in Ajax mail form

Solved! Just add the vaidation in PHP and simply ECHO error messages: function smail(){ $nome = $_REQUEST[‘nome’]; $cognome = $_REQUEST[‘cognome’]; $email = $_REQUEST[’email’]; $telefono = $_REQUEST[‘telefono’]; $numero = $_REQUEST[‘numero’]; $messaggio= $_REQUEST[‘messaggio’]; $prod_mail = $_REQUEST[‘prod_mail’]; $prodotto = $_REQUEST[‘prodotto’]; $confezione = $_REQUEST[‘confezione’]; $prezzo = $_REQUEST[‘prezzo’]; if($nome === ”) { $nome = “<span style=”color:#8c8c8c;”>Nome non inserito</span>”; }; if($cognome … Read more

Contact Form 7 WordPress, checking a few fields, if empty then invalid

I solved my problem add_filter(‘wpcf7_validate_text’, ‘or_input_validation_filter’, 20, 2); function or_input_validation_filter($result, $tag) { if (‘your-link’ == $tag->name) { $your_link = isset($_POST[‘your-link’]) ? trim($_POST[‘your-link’]) : ”; $your_file = (!empty($_FILES[“file-image”][“name”])) ? trim($_FILES[‘file-image’][‘name’]) : ”; if($your_link == ” && $your_file == ”) { $result->invalidate($tag, “One of the fields has not been completed?”); } } return $result; }

Hook before user is created and make some custom validation

You need to add , 10, 3 after your closure to set the hook priority and (more importantly) the number of accepted arguments – otherwise $user_email and $errors will not be passed. add_action( ‘register_post’, function ( $user_login, $user_email, $errors ) { $userIsValid = ValidateUser::make($errors); if(!$userIsValid) { $errors->add( ‘bad_email_domain’, ‘<strong>ERROR</strong>: errors’ ); } }, 10, 3 … Read more