Jump to content

How can I change or delete the captions First Name and Last Name in forms?

Recommended Posts

  • 4 months later...
  • Replies 38
  • Created
  • Last Reply
  • 2 months later...

@groundcontact Thank you for the code, it works great!

I was trying to figure out how to replace and/or remove the captions for addresses as well (Address 1, Address 2, State/Province, Zip/Postal Code, City, Country). It worked fine, except for "State/Province" and "Zip/Postal Code" because the '/' couldn't be typed into your code as is. I'm not a programmer, but after some research I finally figured it out. I'll explain below in case anyone is still trying to figure this out. @Solo.

I used three separate functions to remove 'State' , '/' , and 'Province' since they do not use this label in Norway, by replacing them with nothing (""). For '/' I had to insert a \ before it. I believe it is similar in other parts of Europe, where State/Province is not necessary. The code below removes this easily.


    $('.caption').each(function (i, el) {
       if ($(el).html() != "") {
           $(el).html($(el).html().replace(/State/ig, ""));
       }
   });

   $('.caption').each(function (i, el) {
       if ($(el).html() != "") {
           $(el).html($(el).html().replace(/\//ig, ""));
       }
   });

   $('.caption').each(function (i, el) {
       if ($(el).html() != "") {
           $(el).html($(el).html().replace(/Province/ig, ""));
       }
   });


I did the same for Zip/Postal Code by replacing 'Zip' with 'Postnummer' and removing 'Postal Code' separately. The previous function above already removed all the forward slashes in the form '/'.


    $('.caption').each(function (i, el) {
       if ($(el).html() != "") {
           $(el).html($(el).html().replace(/Zip/ig, "Postnummer"));
       }
   });

   $('.caption').each(function (i, el) {
       if ($(el).html() != "") {
           $(el).html($(el).html().replace(/Postal Code/ig, ""));
       }
   });


Here is @groundcontact's entire code again, with my address labels included within, and a few other modifications:


<script type="text/javascript">

   function addLoadEvent(func) {
       var oldonload = window.onload;
       if (typeof window.onload != 'function') {
           window.onload = func;
       } else {
           window.onload = function () {
               if (oldonload) {
                   oldonload();
               }
               func();
           };
       }
   }
   addLoadEvent(function () {

       // Translate form captions
       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/First Name/ig, "Fornavn"));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Last Name/ig, "Etternavn"));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Address 1/ig, "Adresse 1"));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Address 2/ig, "Adresse 2"));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/City/ig, "Sted"));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/State/ig, ""));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/\//ig, ""));
           }
       });    

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Province/ig, ""));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Zip/ig, "Postnummer"));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Postal Code/ig, ""));
           }
       });

       $('.caption').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Country/ig, "Land"));
           }
       });

       // Translate blog page items
       $('.pagination').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Newer/ig, "Nyere"));
           }
       });

       $('.pagination').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Older/ig, "Eldre"));
           }
       });

       $('.tags-cats').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/tags/ig, "etiketter"));
           }
       });

       $('.excerpt').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Read More/ig, "Les mer"));
           }
       });

       $('.sqs-comment-link.sqs-disqus-comment-link').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Comment/ig, "Kommentere"));
           }
       });

       // Translate dates
       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/January/ig, "Januar"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/February/ig, "Februar"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/March/ig, "Mars"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/April/ig, "April"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/May/ig, "Mai"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/June/ig, "Juni"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/July/ig, "Juli"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/August/ig, "August"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/September/ig, "September"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/October/ig, "Oktober"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/November/ig, "November"));
           }
       });

       $('.post-meta.author-date').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/December/ig, "Desember"));
           }
       });

       // Translate site-wide items
       $('.back-to-top').each(function (i, el) {
           if ($(el).html() != "") {
               $(el).html($(el).html().replace(/Back to Top/ig, "Tilbake til toppen"));
           }
       });

       $('.icon-comments').attr('title', 'Kommentarer');

       $('.icon-share').attr('title', 'Del');

       $('.search-input').attr('placeholder', 'Søke');

   });
</script>

I also modified the .search-input function because it was not working for me. Instead of 'value placeholder' I just used 'placeholder'.

Link to comment
  • 4 months later...
  • 10 months later...

Hi there,

I just tried the above mentioned codes, jut to replace "Last Name" with "Nachname" and "First Name" with "Vorname". I tried different varieties of the code, but nothing worked, it still shows Last Name and First Name.

Anybody here who can help me on this?

Thanks!

Link to comment
  • 1 month later...

Hi, I have tried too and unfortunately, this solution is not working for me. Any idea? Is something is not working anymore in 2017 or something we are missing?

Thanks!

Link to comment
  • 1 month later...
  • 2 months later...
  • 3 weeks later...

Hi @Cragg Your answer is amazing. Wish i could go further. Looking to replace the address parts (i.e. city, zip code, etc) and i'm looking to find the appropriate handle so i can build my own code. I've tried to use the inspector, but i'm no programmer, and this is all chinese to me… Can you help me find what to use instead of (for instance) myFirstname and sqsFirstname?(Hope my question makes sense!)peace out

Link to comment
  • 4 weeks later...

@groundcontact I was able to change the captions on my contact form using the code in your original answer (I didn't go the jQuery route) so thank you for that! I went even further by adding some code I found in another forum so I could also change the placeholder appearing in the MailChimp Newsletter block's email address field.

The only issue I have now is that the JS only seems to affect the forms on first load or reload. If I return to the page the text doesn't switch to the new wording I specified in the JS.

Does anyone know of a way to have the code run each time the page is visited?

Link to comment
  • 1 year later...

The Squarespace code for the newsletter block has changed considerably since this question was originally posted in 2013 and many of the comments were added.

You'll find the latest solution (April 2019) for renaming (translating) the name labels here:

Translate the Squarespace Newsletter Block

-Paul

Squarespace Expert & Professional Developer

Contributors to this forum voluntarily give their time to help you. If we correctly answer your question, please accept the answer by clicking Accept below it (you'll see it when you're logged on). If an answer doesn't help, feel free to ask for more help or wait for other forum users to add their comments and/or answers.

Whenever an accepted answer helps you, please vote it up using the up arrow on the right. This helps other forum users by giving them confidence in an answer.

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment

Archived

This topic is now archived and is closed to further replies.

Guest
This topic is now closed to further replies.
×
×
  • 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.