Jump to content

Contact Form - Change "Submitting" Validation Text

Go to solution Solved by jpeter,

Recommended Posts

Hi,

I'm using the Bergen template in Squarespace 7.1.

I'd like to customize the "event text" that occurs immediately after you have clicked send via the contact form.

The text that appears is "Submitting..." 

I would like to customize this to be a text of my choosing? I believe this was addressed in a thread back in September of 2019 but has since been taken down.

Thank you!

submit text.png

Link to comment
  • Solution

You can add this JS, replace the value of the submittingText variable with with your own:
 

(function () {
  // Text to add when form is submitting.
  var submittingText = 'SUBMITTING!!';

  // Select the node that will be observed for mutations
  var form = document.querySelector('form');
  var submitButton = form.querySelector('input[type="submit"]');
  var submitText = submitButton.value;

  // Options for the observer (which mutations to observe)
  var config = { attributes: true };

  // Create an observer instance linked to the callback function
  var observer = new MutationObserver(function () {

    // Check to see if the form has a `submitting` class.
    var isSubmitting = form.classList.contains('submitting');

    // Toggle betweeen the default submit text and the submitting text.
    if (isSubmitting) {
      submitButton.value = submittingText;
    } else {
      submitButton.value = submitText;
    }
  });
  // Start observing the target node for configured mutations
  observer.observe(form, config);
})();

 

Edited by jpeter
Link to comment

The answer supplied above should work. In case it isn't obvious (to you or to others who read this), the code supplied is JavaScript, so it must be placed in Settings > Advanced > Code Injection > Footer and must be inserted in between 'script' tags. This means, type the following: 

<script>



</script>

and then place the supplied code between these two tags. You'll also need to be on a Business plan or higher (or a trial). 

24 minutes ago, chartreuse said:

Wondering if there's a CSS option?

This isn't possible to do with CSS.

Edited by paul2009

Improve your online store with our extensions.
About: Squarespace Circle Leader since 2017. I value honesty, transparency, appreciation and great design ♥.
Work: Squarespace Developer and founder of SF Digital, building the features Squarespace didn't include™.
Content: Links in my posts may refer to SF Digital products or may be affiliate links.

Buy me a coffee

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.