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

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

Question

Recommended Posts

  • 0

Hi,

How can I change the captions adress 1 and Adress 2, City, Zip Code, telephone in forms, I want to change language?

thanks

Share this post


Link to post
  • 0

@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'.

Edited by musicaldesigner
Updated code with missing Norwegian translations, added note about search function modification.

Share this post


Link to post
  • 0

I just used a Number field instead of Phone, since the phone format in Europe is different than the US and Canada (###-###-####). You can change the name for the number field in the form settings.

Share this post


Link to post
  • 0

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!

Share this post


Link to post
  • 0

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!

Share this post


Link to post
  • 0

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

Share this post


Link to post
  • 0

@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?

Edited by dugost
Initial Revision

Share this post


Link to post
Guest
This topic is now closed to further replies.

×
×
  • Create New...