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

105
Vistas
Password view toggle

I'm trying to do a password visibility toogle because some browsers don't have one like Microsoft Edge.

Here's the code:

<input type="password" name="password" placeholder="Creati o parola">
<input type="checkbox" onclick="visibility()" id="pass_visible">
<label for="pass_visible"><i id="pass_icon" class="bi bi-eye"></i></label>

function visibility()
        {
            var x = document.getElementsByName("password");
            if(x.type === "password")
                {
                    x.type = "text";
                    document.getElementById("pass_icon").className = "bi bi-eye-slash";
                }
            else
                {
                    x.type = "password";
                    document.getElementById("pass_icon").className = "bi bi-eye";
                }
        }

The problem is that for some reason it changes only "pass_icon". The type for x stays the same.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to switch the type from password to text and vice versa when you press the toggle switch.

<input type="password" name="password" id="password" placeholder="Creati o parola">

function visibility()
        {
          const passwordEle = document.getElementById('password');
          const type = passwordEle.getAttribute('type');
          passwordEle.setAttribute('type', type === 'password' ? 'text' :'password');
        }
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