skip to Main Content

So I m working on a WordPress site I made a form using the formidable plugin. I want the form submitted success message automatically removes after 10 seconds. how to remove form submit message after 10 seconds automatically in the WordPress site.

2

Answers


  1. Don’t know about that plugin but a few lines of JS should do the trick.

    Let’s say the element that wraps your success message has a class called notice-container and the form element has the id form21

    document.addEventListener('DOMContentLoaded', function () {
        let container = document.querySelector('.notice-container'),
            form = document.querySelector('#form21');
    
        if (form != null) {
            form.addEventListener('submit', function () {       
                setTimeout(function(){
                    container = document.querySelector('.notice-container');
                    if (container == null) return; // abort if element isn't available
    
                    container.style.display = 'none';
                }, 10000);
            });
        }
    });
    

    Place this code anywhere on your page and you’re good to go.

    P.S: Don’t forget to replace the notice-container and form21 values accordingly to your form

    Login or Signup to reply.
  2. Here is the official document of the Formidable form. https://formidableforms.com/knowledgebase/javascript-examples/javascript-after-form-submit/

    You can try something below:

    <script type="text/javascript">
        jQuery(document).ready(function($){
            $(".frm_message").delay(10000).fadeOut(1000); // change 5000 to number of seconds in milliseconds  
        });
    </script>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search