How to hide newsletter block last name field on Squarespace 7.1

With the newsletter block, you may want to omit the last name field.  However, there isn't a way of doing this other than using some Javascript code to achieve this.

The following This tutorial will show you how to hide the newsletter block. This solution works on Squarespace 7.1.

Complexity: Easy


Step 1

From your Squarespace account, simply add the following JavaScript below to Settings > Advanced > Code Injection > Footer and then save your changes.

<script>
 
  (function() {
    window.addEventListener('DOMContentLoaded', pcLastName);

    function pcLastName() {
      
      let pclNames = document.querySelectorAll('.last-name input');
      let pclNameFields = document.querySelectorAll('.last-name'), i, j;

       for (i=0; i < pclNames.length; i++) {

          pclNames[i].value = "-";  // The Last Name still needs a value
           
            for (j=0; j < pclNameFields.length; j++) {

                   pclNameFields[j].style.display = "none";
            }
        }
     }
  }());
</script>

Please note:

  • The last name will still be recorded in the backed but it will have the value “-”.

  • This code will work site wide on other newsletter form.

newsletter


All work in this guide is provided ?“AS IS”. Other than as provided in this agreement, this guide makes no other warranties, express or implied, and hereby disclaims all implied warranties, including any warranty of fitness for a particular purpose.

If you require professional advice, we recommend that you purchase the services of a developer.

Primitus Consultancy

We work with small and medium-sized businesses to help create a professional online presence. We provide a one shop full-service design studio in London, United Kingdom. 

https://primitusconsultancy.co.uk
Previous
Previous

How to style Squarespace reCAPTCHA

Next
Next

How to add a full scrollable website page on Squarespace