KawebDev Posted August 23, 2023 Share Posted August 23, 2023 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
paul2009 Posted August 23, 2023 Share Posted August 23, 2023 (edited) 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 August 23, 2023 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
KawebDev Posted August 25, 2023 Author Share Posted August 25, 2023 Is there any way to do the placeholders with a React friendly code instead? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment