Jump to content

Form fields title inside the field itself

Recommended Posts

2 hours ago, AJPerformance said:

Site URL: https://www.ajpgroup.com/contact-us

Hi, I'd like to know if its possible to have the form field titles show inside the fields themselves until your start typing as shown in the picture below. And if possible, can someone show me how i can do it. Thank you!

Screenshot 2022-04-21 at 5.15.22 PM.png

I think we can achieve it with some Js code to set placeholder for input element

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
29 minutes ago, AJPerformance said:

im not very versed with Js so if you dont mind, can you help me figure it out please? 

You can try the following code in Home > Settings > Advanced > Code Injection, choose the footer

<script>
  (function() {
    window.addEventListener('DOMContentLoaded', () => {
      const placeholders = document.querySelectorAll('.field');
      if(placeholders.length) {
        placeholders.forEach(holder => {
          const inputEl = holder.querySelector('input, textarea.field-element');
          const labelEl = holder.querySelector('.caption-text, .title').innerText;
          if(inputEl && labelEl) {
            inputEl.setAttribute('placeholder', labelEl);
          }
        })
      }
    });
  })()
</script>

Let me know how it works on your site

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

My testing

image.thumb.png.280c64d8981e179943fa4362bdb0d6f5.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
2 hours ago, bangank36 said:

You can try the following code in Home > Settings > Advanced > Code Injection, choose the footer

<script>
  (function() {
    window.addEventListener('DOMContentLoaded', () => {
      const placeholders = document.querySelectorAll('.field');
      if(placeholders.length) {
        placeholders.forEach(holder => {
          const inputEl = holder.querySelector('input, textarea.field-element');
          const labelEl = holder.querySelector('.caption-text, .title').innerText;
          if(inputEl && labelEl) {
            inputEl.setAttribute('placeholder', labelEl);
          }
        })
      }
    });
  })()
</script>

Let me know how it works on your site

It works perfectly, thank you bangank :)))

Link to comment
  • 11 months later...

I tried this but it still shows the fields above the box as well and not like the original image where the field description is only within the box. Is there a way to do this?
Is there also a way to show more of a landscape option similar to image below, rather than it being completely vertical?

image.png.37b989bc74a4df1678429a6667a36513.png

Link to comment
On 4/5/2023 at 8:36 PM, MaureenC said:

I tried this but it still shows the fields above the box as well and not like the original image where the field description is only within the box. Is there a way to do this?
Is there also a way to show more of a landscape option similar to image below, rather than it being completely vertical?

image.png.37b989bc74a4df1678429a6667a36513.png

Can you share link to this 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

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.