Making custom meta box required (with error message if not filled in) on Gutenberg
Making custom meta box required (with error message if not filled in) on Gutenberg
Making custom meta box required (with error message if not filled in) on Gutenberg
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.
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
How to validate image with specific height and width selection in media selector
Code for front end validation for forms not working
validation email signup form buddypress
How to add custom regex validation to WPForms password field
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; }
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
I understand your hesitation about using 3rd party plugins, but form handling is a primary candidate to offload to one. That’s coming from someone who always tries to build bespoke. There is a reason why several well-established WP form plugins exist – forms are tedious to build & handle manually, prone to errors & unwittingly … Read more