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

104
Views
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 answers
Answer question

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 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!