Jump to content

Custom Newsletter Block w/ only First Name & Email

Go to solution Solved by tuanphan,

Recommended Posts

  • 1 month later...
  • Solution

Add to Code Injection Footer

<script>
  window.Squarespace.onInitialize(Y, function(){
  sfSeconds = document.querySelector('.last-name input');
  sfSeconds.value = "NA";
  sfSecondsField = document.querySelector('.last-name');
  sfSecondsField.style.display = "none";
});
</script>

code by @paul2009, edited some lines by me.

7 hours ago, Pooks said:

Currently it is first and last name required or no name at all.

I would be really interested in the ability to just have first name and email as well.

 

Edited by tuanphan
tag

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 months later...
  • 3 months later...
  • 1 month later...
1 hour ago, JennyJenny said:

Are you able to tell what I did wrong?

Please give us the URL for the page where you want to suppress the Last Name field. If you've not already done so please set up a site-wide password. Post the password here and then we can take a look at your issue.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
  • 2 weeks later...
On 2/1/2020 at 1:02 AM, tuanphan said:

Add to Code Injection Footer


<script>
  window.Squarespace.onInitialize(Y, function(){
  sfSeconds = document.querySelector('.last-name input');
  sfSeconds.value = "NA";
  sfSecondsField = document.querySelector('.last-name');
  sfSecondsField.style.display = "none";
});
</script>

code by @paul2009, edited some lines by me.

 

Hello! This worked for me on the newsletter block on my homepage, (thank you!) but I have another newsletter block on my contact page, and the removal of the last name does not reflect there. Any way to make this global for all newsletter blocks? I can share site and pw if necessary. Using Harris Template in York Family, so it's not a footer block like the Brine sites.

Link to comment
11 hours ago, michenator said:

Hello! This worked for me on the newsletter block on my homepage, (thank you!) but I have another newsletter block on my contact page, and the removal of the last name does not reflect there. Any way to make this global for all newsletter blocks? I can share site and pw if necessary. Using Harris Template in York Family, so it's not a footer block like the Brine sites.

Can you share link to contact page? We can check easier.

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
18 hours ago, michenator said:

Thank you! https://tankarselfstorage.squarespace.com/contact // pw: packlikeapro

Newsletter blocks are at bottom of Contact page and bottom of Home page.

I think above code should work for all forms. If it still doesn't work, try disable Ajax Loading (Home > Design > Site Styles > Ajax Loading)

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 weeks later...

Did you ever sort the 7.1 error @tuanphan ?

Your older code seems to work fine:
 

Quote

 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"
  })
      
     
 });

 

Edited by Kwamzilla

Work With Me 🖥️💻📱

Please remember to tag me so that I get a notification and respond to your help requests.

If my answers have helped you, please drop a like and mark my answer as best to help other users find solutions quickly.

You can also thank me or make requests by buying me a coffee . (Caffeine fuels me to take more requests)

For Squarespace Tips & Tricks, visit @squareskills (Youtube 📺 Tutorials)

For Premium and FREE plugins, visit Squareskills (Plugin Store) 🧩

Some links may be affiliate/referral links.

Link to comment
  • 6 months later...
On 2/1/2020 at 6:02 AM, tuanphan said:

Add to Code Injection Footer



<script>
  window.Squarespace.onInitialize(Y, function(){
  sfSeconds = document.querySelector('.last-name input');
  sfSeconds.value = "NA";
  sfSecondsField = document.querySelector('.last-name');
  sfSecondsField.style.display = "none";
});
</script>

code by @paul2009, edited some lines by me.

 

The code here seems to work well on the surface, however it sets the value of Last Name for the new contact, literally to the text string 'NA', rather than it being null/empty, which is not quite the desired behaviour. You would need to take care not to include Last Name in any of your correspondence, to avoid emailing contacts something like, "Hello Ffion NA"! 

Screenshot 2021-05-13 at 16.47.39.png

Edited by newstaircase
Added screenshot
Link to comment
19 hours ago, newstaircase said:

The code here seems to work well on the surface, however it sets the value of Last Name for the new contact, literally to the text string 'NA', rather than it being null/empty, which is not quite the desired behaviour. You would need to take care not to include Last Name in any of your correspondence, to avoid emailing contacts something like, "Hello Ffion NA"! 

Screenshot 2021-05-13 at 16.47.39.png

Add new code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.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"
  })
      
     
 });
</script>

 

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 weeks later...
On 5/24/2021 at 7:30 PM, kkurtz said:

Site URL: https://midlandfoodtours.ca

How do I delete the 'last name' field in a newsletter block? It's on the website page linked to the 'Subscribe for Updates' button on my homepage.  I've tried different custom CSS in several forum posts but have not had any luck. 

website password: mft4567*

 

It looks like you solved this?

 

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Thanks for being so thorough on the site!

I'd still like to know how to have a newsletter block with just blocks for first name and email address.  Until I know how to do it, I went with the option to only require an email address. 

I do need help to fix the five other issues.  Some of them were issues on a tablet, and I've never seen my site displayed on a tablet before.

Thank you!

 

Link to comment
18 hours ago, kkurtz said:

Thanks for being so thorough on the site!

I'd still like to know how to have a newsletter block with just blocks for first name and email address.  Until I know how to do it, I went with the option to only require an email address. 

I do need help to fix the five other issues.  Some of them were issues on a tablet, and I've never seen my site displayed on a tablet before.

Thank you!

 

Can you enable name field? We can check easier

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 3 weeks later...
On 5/29/2021 at 4:23 AM, kkurtz said:

I've enabled the name field again.

 

Use this new code

<script>
  window.Squarespace.onInitialize(Y, function(){
  sfSeconds = document.querySelector('.last-name input');
  sfSeconds.value = " ";
  sfSecondsField = document.querySelector('.last-name');
  sfSecondsField.style.display = "none";
});
</script>

Code by Sf.digital

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

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

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.