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

123
Views
Can you create a basic password validation form that redirects to another page if the password is correct?

I'm still gripping the ropes of HTML, and I was wondering if you could create a basic form that checks if the entered item is correct, then do something like send an alert or redirect to another page. I already know how to create redirects and alerts but I'm just having trouble with the password part. Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Unfortunately with the nature of JavaScript the password will always be able to obtained from the source code, unless you link it with a backend API Request.

But here is a very simple example with the password opensesame.

function submitHandler(event) {
  const formData = new FormData(event.target);
  const password = "opensesame";
  if (formData.get("password") === password) {
    alert("You're In!");
  }
  event.preventDefault();
  return false;
}

const form = document.getElementById("form");
form.addEventListener("submit", submitHandler);
<form id="form">
  <label>Password: <input name="password" type="password"></label>
  <br><br>
  <button type="submit">Submit form</button>
</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!