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

245
Vistas
javascript: how can I print an error message but only if there is already something in the text box

I have 2 text boxes. Inputs cannot match but I don't want error message to show up when they're both empty only when there has been something inputed in both boxes. how do I do this?

function validate() {
  var errorMessage = "";

  var textbox4Input = document.getElementById("fictional");
  var textbox5Input = document.getElementById("real");



  var textbox4 = textbox4Input.value.trim();
  var textbox5 = textbox5Input.value.trim();



  textbox4Input.value = textbox4;
  textbox5Input.value = textbox5;

if (textbox4 === textbox5) {
    errorMessage += "Favorite fictional place & favorite real place cannot be the same.<br>"
}
  return errorMessage;

}
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