Jump to content

Adding Placeholders to the Name and Phone Number fields

Recommended Posts

I have used the following code to try and inject the placeholder text into the form however its not working, any help would be greatly appreciated. 

<script>
(function() {
document.querySelector(".first-name input").setAttribute("placeholder", "First name");
document.querySelector(".last-name input").setAttribute("placeholder", "Last name");
document.querySelector(".phone input").setAttribute("placeholder", "Mobile Telephone No.");
})()
</script>

 

I also added the following to the header as well: 

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

 

Link to comment
  • Replies 2
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

1 hour ago, KawebDev said:

I have used the following code to try and inject the placeholder text into the form however its not working

Sadly this won't work now because Form Blocks were updated in May 2023 to use React. See earlier threads for more background.

1 hour ago, KawebDev said:

I also added the following to the header as well: 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Also, it is not necessary to add jQuery to the header when you are using pure JavaScript like the example you've quoted. Adding this will just slow your site down unnecessarily.

Edited by paul2009

About me: I'm Paul. A SQSP User for 18 yrs, I joined Circle when it launched in 2016 and have been a Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL, providing expertise and extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee fuels my work.

Book paid help with a Squarespace Domain

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.