Jump to content

Remove Last Name from Newsletter Block

Go to solution Solved by tuanphan,

Recommended Posts

Hi, 

I'm working on a client site and would like to remove the Last Name field from a Newsletter block on the Home page. 

I added the following code to the Code Injection Footer and it appears to work but when I go back into Edit mode the Last Name field reappears. 

Any ideas what I'm doing wrong here? 

Thank you! 

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>
 const lnames = document.querySelectorAll('.last-name input')
   const lnameFields = document.querySelectorAll('.last-name')
  $(document).ready(function(){

     lnames.forEach(lname => {
   lname.value = "-"
  })

     lnameFields.forEach(lnameField => {
     lnameField.style.display = "none"
  })

Link to comment
  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

@tuanphan Thank you for the reply! I guess I didn't copy/paste the entire code in my post, I did have the closing </script> tag at the end. Sorry about that. 

I tried removing it and starting over but the code still isn't working. Does the rest of the code look correct to you? It's strange because it looks like it removes the Last Name field when I'm still the Code injection page but when I go into Edit mode the field comes back. Any ideas? 

Link to comment

Try this new code. If it doesn't work, please share site url, we can check easier

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
lastName = document.querySelector('.last-name input');
lastName.value = "NA";
hideLastName = document.querySelector('.last-name');
hideLastName.style.display = "none";
});
</script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

@tuanphan Thank you again! The new code seemed to do the trick when I test the website with a password, but in Edit mode the Last Name field still appears. Seems strange to me but as long as it's working on the live site I'm happy. Thank you so much for your help with this. 

Link to comment
  • Solution
23 hours ago, AbigailH said:

@tuanphan Thank you again! The new code seemed to do the trick when I test the website with a password, but in Edit mode the Last Name field still appears. Seems strange to me but as long as it's working on the live site I'm happy. Thank you so much for your help with this. 

If the code doesn't work in edit mode, will need to access your site backend to check this. If you can add me as a contributor, I can check easier

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

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.