Jump to content

Lightbox form: How to add form field placeholders?

Go to solution Solved by creedon,

Recommended Posts

I used these tips to get placeholder text added for first name, last name, and phone several months ago, but with Squarespace's recent form changes those additions have all broken. I assume this has happened to everyone using the method described in this thread. Does anyone know how the code needs to be edited in light of Squarespace's changes to get the placeholder text working again?

This is what I have that was working great until the last week or two:

 

<script>

  $( ( ) => {
  
    /*
    
      add placeholder text to first and last name fields in "Get in touch!"
      form for v7.1 site.
      
      SS version : 7.1
      
      */
      
    const dataFormId = '633881aed705ef0f2a50d02b';
    const firstNamePlaceholderText = '*First Name';
    const lastNamePlaceholderText = '*Last Name';
    
    // do not change anything below
    
    let $form = $( '[data-form-id="' + dataFormId + '"]' );
    
    $( '.first-name input', $form )
    
      .attr ( 'placeholder', firstNamePlaceholderText );
      
    $( '.last-name input', $form )
    
      .attr ( 'placeholder', lastNamePlaceholderText );
    
$( '.phone .three-digits input', $form )

  .attr ( 'placeholder', '###' );
  
$( '.phone .four-digits input', $form )

  .attr ( 'placeholder', '####' );
      
    } );
    
  </script>


 

Link to comment
On 5/16/2023 at 12:32 AM, pnel said:

I used these tips to get placeholder text added for first name, last name, and phone several months ago, but with Squarespace's recent form changes those additions have all broken. I assume this has happened to everyone using the method described in this thread. Does anyone know how the code needs to be edited in light of Squarespace's changes to get the placeholder text working again?

This is what I have that was working great until the last week or two:

 

<script>

  $( ( ) => {
  
    /*
    
      add placeholder text to first and last name fields in "Get in touch!"
      form for v7.1 site.
      
      SS version : 7.1
      
      */
      
    const dataFormId = '633881aed705ef0f2a50d02b';
    const firstNamePlaceholderText = '*First Name';
    const lastNamePlaceholderText = '*Last Name';
    
    // do not change anything below
    
    let $form = $( '[data-form-id="' + dataFormId + '"]' );
    
    $( '.first-name input', $form )
    
      .attr ( 'placeholder', firstNamePlaceholderText );
      
    $( '.last-name input', $form )
    
      .attr ( 'placeholder', lastNamePlaceholderText );
    
$( '.phone .three-digits input', $form )

  .attr ( 'placeholder', '###' );
  
$( '.phone .four-digits input', $form )

  .attr ( 'placeholder', '####' );
      
    } );
    
  </script>


 

Do you still need help?

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.