Jump to content

How can I change the language of hour & minute captions in forms?

Recommended Posts

Site URL: https://www.dlopezlaw.com/es/comunicacion

I am creating a multilingual site and have managed to do everything I need it to do except changing the time caption (Hour and Minute to Hora and Minuto) on the contact form on the Spanish version. I was able to follow a previous question to change the first name and last name caption but can't figure out how to do the same for the Hour and Minute (I am hiding the second option). 

Link to comment
  • Replies 6
  • Views 496
  • Created
  • Last Reply

Add to Page Settings > Advanced > Header

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
jQuery(function($){
    $(".field.hour.two-digits input").html(function() { 
          return $(this).html().replace("Hour", "new hour text");  
    });
      $(".field.minute.two-digits input").html(function() { 
          return $(this).html().replace("Minute", "minute new text");  
    });
});
</script>

 

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

Thank you! I tried to add it to the code I already had in there for the first name and last name translation and it is not working. Any thoughts? Here is what I currently have:

 

<script>
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() {  
 sqsFirstName = document.getElementsByClassName("caption")[0].innerHTML;
 myFirstName = sqsFirstName.replace("First Name", "Primer nombre");
 document.getElementsByClassName("caption")[0].innerHTML = myFirstName;

 sqsLastName = document.getElementsByClassName("caption")[1].innerHTML;
 myLastName = sqsLastName.replace("Last Name", "Apellido");
 document.getElementsByClassName("caption")[1].innerHTML = myLastName;
  
});

</script>

Link to comment
1 hour ago, Rosie33 said:

Added it back and I still don't see a change. Thanks in advance for your help.

Remove code I sent and use this

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
jQuery(function($){
    $(".field.hour.two-digits .caption").html(function() { 
          return $(this).html().replace("Hour", "new hour text");  
    });
      $(".field.minute.two-digits .caption").html(function() { 
          return $(this).html().replace("Minute", "minute new text");  
    });
});
</script>

 

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

Archived

This topic is now archived and is 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.