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

178
Vistas
How to redirect to specific URL depending on password entered?

I have a password-protected button that will redirect a user to a specific URL when the password is entered. It works fine but what I want to do is depending on what password the user enters, they will be taken to a URL which corresponds to what they entered. Let's say 'test' was entered in the box, this will redirect users to 'test.com/test/test.html' but if the user entered 'test1' then they'll be redirected to 'test.com/test1/test1.html'. Is there any way to do this? This is my code:

<body>
  <div id="title">
    <span>WELCOME TO</span> <span style="font-size:80px"><br>
        AiZen</span>
  </div>
  <div class="button_container">
    <button class="btn" id="HyperLink1" onclick="location.href='home.html';return ValidatePassword()"><span>Enter Now</span></button>
  </div>
  <script>
    function ValidatePassword() {
      var a = prompt("Enter the password. You know it right?", "");
      if (a == "test") {
        return true
      } else {
        alert("No match. Try again.")
      }
      return false
    }
  </script>
</body>

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

0

Assuming that you don't have access to a backend app server, or that you don't want to use it for this, you can do something like

document.getElementById("name").addEventListener("input", function(e) {
      var val = e.target.value;
      var form = e.target.closest("form");
    //test.com/test1/test1.html
      form.action = "http://test.com/" + val + "/" + val + ".html";
      console.log("action: " + form.action);
    });
<form>
    <input name="name" id="name" />
    <input type="submit">
    </form>

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