Search code examples
mautic

How to change the sending message "Please wait..." of the form button after it is already loaded?


I'm calling a Mautic form using its token instead of a manual copy.

{form = 5}

When the form is submitted, the button text temporarily changes to "Please wait ...".
However, I need it to be a different text.

If I implement the form by manual copy, I could modify this message just by declaring this variable.

var MauticLang = {
  'submittingMessage': "Another text"
}

I tried this in a script within the HTML where the form is, after and before it, also after the DOM is loaded, but there was no effect. I investigated the code on the page as much as I could, but to no avail. I have researched, but can't find a solution anywhere.

How to change the button sending message after the form is already loaded?


Solution

  • Modify submittingMessage value is the way to go.

    MauticLang.submittingMessage = "Hold your horses...";
    

    Or

    MauticLang = {
      'submittingMessage': "Hold your horses..."
    }
    

    In addition, to ensure that you are modifying it after Mautic is loaded, you can use setTimeOut with load event listener on window.

    Something like 5 seconds, enough time to have the form not fully filled by the user.
    So, the final solution could be:

    window.addEventListener('load', function() {
      setTimeout(function() {
        MauticLang.submittingMessage = "Hold your horses..";
      }, 5000);
    });