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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s