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.
If you have any questions or need any help with your Squarespace website design, you can book a 1:1 consultation.
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.