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

171
Vistas
reportValidity not showing message

I created a function to indicate when the input passwords do not match, but having issues with showing the built-in HTML form verification message.

When I run the debugger I do see that the custom message gets displayed, but when the function ends so those the message.

Would anyone know why the message won't persist?

function validatePassword() {
  debugger;
  let p1 = document.getElementById('password');
  let p2 = document.getElementById('confirm_password');
  p2.setCustomValidity("");

  if (p1.value != p2.value && p1.value != '' && p2.value != '') {
    p2.setCustomValidity("Passwords do not match");
    p2.reportValidity();


  }


}
<form>

  <div>
    <label for="">Password</label>
    <input type="password" id='password' onchange='validatePassword()' required>
  </div>

  <br>

  <div>
    <label for="">Confirm Password</label>
    <input type="password" id='confirm_password' onchange='validatePassword()' required>
  </div>

  <br>
  <input type="submit" value="Send">
</form>

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