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

159
Vistas
Validación de formulario de entrada múltiple de JavaScript

Estoy tratando de usar Javascript para validar la entrada del usuario antes de las redirecciones de página. Los usuarios pueden ingresar la identificación del estudiante, el nombre o el sexo y, según su entrada, serán redirigidos a una URL.

Sin embargo, parece que no obtengo las entradas múltiples correctamente en mi javascript y no sucedió nada cuando se hace clic en el botón Enviar.

He probado diferentes soluciones que encontré aquí.

vea mi código JavaScript a continuación;

 var attempt = 3; // Variable to count number of attempts. // Below function Executes on click of login button. function validate(){ var username = document.getElementById("studentid").value; if ( studentid == "12345" || studentid == "Daniel" || studentid == "Boy"){ alert ("Correct Input"); window.location = "https://www.google.com"; // Redirecting to other page. return false; } else{ attempt --;// Decrementing by one. alert("ATTENTION!\nInvalid student ID!\nNot associated with any student\nYou have left "+attempt+" attempt;"); // Disabling fields after 3 attempts. if( attempt == 0){ document.getElementById("studentid").disabled = true; document.getElementById("submit").disabled = true; return false; } } }

He intentado usar las soluciones a continuación;

 if ( studentid == "#12345, #Daniel, #Boy"));{ alert ("correct input"); window.location = "https://www.google.com"; // Redirecting to other page. if ( studentid == '12345', 'Daniel', 'Boy'){ alert ("correct input"); window.location = "https://www.amazon.com"; // Redirecting to other page.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

¡Después de tantos intentos, por fin lo conseguí!

 var attempt = 3; function check(form) { if(form.studentid.value == "12345" || form.studentid.value == "DANIEL" || form.studentid.value == "BOY") { window.location.replace('https://www.google.com') return false; } else { attempt --;// Decrementing by one. alert("ATTENTION!\nInvalid student ID!\nNot associated with any student!\nYou have left "+attempt+" attempt;"); // Disabling fields after 3 attempts. if( attempt == 0){ document.getElementById("studentid").disabled = true; document.getElementById("submit").disabled = true; return false; } } }

about 4 years ago · Juan Pablo Isaza Denunciar
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