Pawan Kumawat

Contact Form 7’s Validation In PopUp

When CF7 form (Contact form 7) is placed in elementor’s popup the issue is that the popup closes before it can show the after submit confirmation text or submission error.

Usually PopUp closes before showing Contact Form 7’s validation error after submit. Because form loads using ajax , so js not load for dynamic html. for stopping this error we need to re initialize the form after popup loads.

 

We need to reinitialize the form after the opening of the popup.

We can use the script in “wp_footer” action.

 

function elementor_popup_reinitialize() {
?>
   <script>
     window.addEventListener('DOMContentLoaded', function() {
        jQuery(document).on('elementor/popup/show', () => {
           for(var i = 0; i < jQuery(".wpcf7-form").length ; i++) {
             wpcf7.init(jQuery(".wpcf7-form")[i]);   
           }
        });
     });
   </script>
<?php
}
add_action('wp_footer','elementor_popup_reinitialize ');

 

Place this code in your theme’s functions.php file and se the results.

 

Categories

Related Blogs

WordPress Ajax login

To implement Ajax login in WordPress, you can follow these steps: 1. Open the theme’s functions.php file in your WordPress

Top Quick View Plugins WooCommerce

There are several popular WooCommerce quick view plugins that provide a convenient way for customers to view product details without leaving the current page. Keep in mind that the popularity of plugins can change over time, so it’s a good idea to check for the latest information and reviews before making a decision.

WooCommerce: Check if Product ID is in the Cart

To check if a specific product ID is in the cart in WooCommerce, you can use the `woocommerce_before_cart` action hook, which is fired before the cart page is displayed. Here’s how you can achieve this: