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

142
Vistas
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 Respuestas
Responde la pregunta

0

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

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