Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda