Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Created October 13, 2016 19:24
Show Gist options
  • Select an option

  • Save AllThingsSmitty/452821395961a3800c077130b864fdbd to your computer and use it in GitHub Desktop.

Select an option

Save AllThingsSmitty/452821395961a3800c077130b864fdbd to your computer and use it in GitHub Desktop.

Revisions

  1. AllThingsSmitty revised this gist Oct 13, 2016. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions form.html
    Original file line number Diff line number Diff line change
    @@ -1,4 +0,0 @@
    <form>
    <input id="txtPassword" type="password" autocomplete="off" />
    <span id="btnToggle" class="fa fa-eye"></span>
    </form>
  2. AllThingsSmitty created this gist Oct 13, 2016.
    4 changes: 4 additions & 0 deletions form.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    <form>
    <input id="txtPassword" type="password" autocomplete="off" />
    <span id="btnToggle" class="fa fa-eye"></span>
    </form>
    13 changes: 13 additions & 0 deletions toggle.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function togglePassword() {
    let passwordInput = document.getElementById('txtPassword');
    if (passwordInput.type === 'password') {
    passwordInput.type = 'text';
    } else {
    passwordInput.type = 'password';
    }
    }

    (function () {
    let toggle = document.getElementById('btnToggle');
    toggle.addEventListener('click', togglePassword, false);
    })();