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.3k
  • 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

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original 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 completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

Would you like your customers to be able to mark their favourite products in your Squarespace store?

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.