today:
441
yesterday:
719
Total:
1,770,225

Technology

Show and hide password using JavaScript

admin 2020.07.06 00:03 Views : 54878

2372224457_0mN6jgo9_ae5850397819ba2b59eae7277a6e272fd0e28e46.jpg

POST TEST (ITEM)

<i id="pass-status" class="fa fa-eye field-icon" aria-hidden="trun" onClick="viewPassword()"></i>

 

Function and Global Variable Declaration (Page)

function viewPassword()

{

  var passwordInput = document.getElementById('P101_PASSWORD');

  var passStatus = document.getElementById('pass-status');

 

  if (passwordInput.type == 'password'){

    passwordInput.type='text';

    passStatus.className='fa fa-eye-slash field-icon';

 

  }

  else{

    passwordInput.type = 'password';

    passStatus.className='fa fa-eye field-icon';

  }

}

 

Inline (Page)

.field-icon{

   float: right;

   margin-left: -25px;

   margin-top: 11px;

   position: relative;

   z-index: 2;

}