Add Email field to Form Submission Success Message

To add Email field to Form Submission Success Message in Squarespace like this.

Here I will guide you use Custom Code. However if you also use this free tool to create Contact Form, so you can add Email to Submission Success Message without complex code.

#1. Make sure you added Email Fields

#2. Make sure you added text to Success Message

#3. Hover on Page where you use Form Block > Click Gear icon

#4. Click Advanced > Paste this code

<script>
(function() {
  const EMAIL_KEY = 'sqs_form_email';

  document.addEventListener('input', function(e) {
    const form = e.target.closest('form');
    if (form) {
      const emailInput = form.querySelector('input[type="email"], input[name="email"]');
      if (emailInput) {
        sessionStorage.setItem(EMAIL_KEY, emailInput.value.trim());
      }
    }
  }, true);

  function injectEmail() {
    const storedEmail = sessionStorage.getItem(EMAIL_KEY);
    if (!storedEmail) return;

    const selectors = [
      '.form-submission-text p',
      '.sqs-form-block-submission-html p',
      '.form-submission-html p'
    ];

    selectors.forEach(selector => {
      const elements = document.querySelectorAll(selector);
      elements.forEach(el => {
        const text = el.innerText.trim();
        if (text.toLowerCase().includes('i will send enquire to') && !el.dataset.emailNamed) {
          el.innerText = text + ' ' + storedEmail + '.';
          el.dataset.emailNamed = 'true';
          setTimeout(() => sessionStorage.removeItem(EMAIL_KEY), 3000);
        }
      });
    });
  }

  setInterval(injectEmail, 100);
})();
</script>

#5. If you need to add other fields to Success Message, you can use this AI Tool, I can help you tweak this on your Squarespace site.

#6. If you use tool I mentioned in top of post, you can add this syntax to tool.

Thank you. I will send enquire to [email]