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

149
Visualizações
HTML .value checking not working properly

I have been working on a little coding project for my friends. This includes a somewhat password system that changes your username. I implemented this so that impersonation was harder to do.

<main class="join-main">
    <label for="password">Password</label>
    <input type="password" name="password" id="password" placeholder="Enter password..." required />
    <button type="button" onclick="fn1()">Check ig</button>
    <script>
        function fn1() {
            let pswvalue = document.getElementById("password").value

            if (pswvalue = "1234") {
                document.getElementById("username").value = "Hello"
            } else {
                return;
            }
        }
    </script>
    <form action="chat.html">
      <div class="form-control">
        <label for="username">Logging Into:</label>
        <input
          type="text"
          name="username"
          id="username"
          placeholder="The User you are logging into will appear here." 
          readonly
        />
      </div>
    </form>

For some reason, even if the password isn't "1234", The username still changes to Hello. Any suggestions on how to fix it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It should be if (pswvalue === "1234") since we are comparing two stings.

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