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

181
Views
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 answers
Answer question

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 Report
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!