Ecommerce Shopify WordPress Discussion

Hide Contact Form 7 and show DIV after Sent

I want to hide my Contact Form 7 after validation and a successful sent, and show a div in its place. I'm using the shortcode ID. Its not working. Would it be easier to wrap the form in a div and hide that instead? <script type="text/javascript"> document.addEventListener( 'wpcf7mailsent', function( event) { if ( '9a5f5ae' == event.detail.contactFormId ) { var hid = document.getElementsByClassName("qtWRP2"); if(hid[0].offsetWidth > 0 && hid[0].offsetHeight > 0) { hid[0].style.visibility = "visible"; } } }, true ); </script>
You don't need JavaScript to hide the form (and the custom div). Just add the following to your CSS: .qtWRP2 {display: none;} .wpcf7-form.sent p { //remove the p if you want to hide the confirmation box displayed by C7 as well display: none; } And then change the visibility of the custom div that you have like this: <script> document.querySelector('.wpcf7').addEventListener('wpcf7submit', () => { const c7form = document.querySelector('.wpcf7-form'); const hid = document.querySelector("#test"); if (c7form.classList.contains('sent')) { = "block"; } }); </script>

February 4, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.