Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Form fields title inside the field itself


AJPerformance

Question

5 answers to this question

Recommended Posts

  • 0
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

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Youtube Gallery for Squarespace
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 0
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

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Youtube Gallery for Squarespace
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 0

My testing

image.thumb.png.280c64d8981e179943fa4362bdb0d6f5.png

Greeting, it's BaNgan from BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Youtube Gallery for Squarespace
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
  • 0
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...