Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

210
Vistas
How to change the language of the validity message for all the inputs using JavaScript?

I have an email and a password input with required and instead of "Please fill out this field.", I want a message in another language.

I found from relevant questions that I must use the setCustomValidity() but I don't know how to implement it correctly since the examples were using inline JavaScript or jQuery or they changed the message for one input.

While using this code:

function validate() {
    const inputs = document.getElementsByTagName('input');

    for (let input of inputs) {
        let validityState = input.validity;

        if (validityState.valueMissing) {
            input.setCustomValidity('Παρακαλώ συμπλήρωσε το πεδίο.');
        } else if (validityState.typeMismatch) {
            input.setCustomValidity('Πρέπει να υπάρχει ένα «@»!')
        } else {
            input.setCustomValidity('');
        }

        input.reportValidity();
    }
}
document.getElementsByTagName('input').innerHTML = validate();

I was able to change the language but I noticed that when I typed on the email input, the validity message would stay even if the input wasn't empty!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda