Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!