Show or Hide Password in Javascript

Add below javascript file before closing head

<script>
function toggle_password(target){
    var d = document;
    var tag = d.getElementById(target);
    
    var tag2 = d.getElementById("showhide");

    if (tag2.innerHTML == 'Show'){
        tag.setAttribute('type', 'text');   
        tag2.innerHTML = 'Hide';

    } else {
        tag.setAttribute('type', 'password');   
        tag2.innerHTML = 'Show';
    }
}
</script>

Html:

 Password : <input type="password" name="usr_pwd" id="pwd0" required/> <a href="#" onclick="toggle_password('pwd0');" id="showhide">Show</a>