# On password masking and usability

DevFeed: [On password masking and usability](<https://devfeed.tech/articles/on-password-masking-and-usability-51955.md>)

Original publisher: [Read original article](<https://lea.verou.me/2009/06/on-password-masking-and-usability/>)

Author: Lea Verou

Published: 2009-06-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [passwords](<https://devfeed.tech/topics/passwords.md>), [Usability](<https://devfeed.tech/topics/usability.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Internet Explorer](<https://devfeed.tech/topics/internet-explorer.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>), [Document Object Model (DOM)](<https://devfeed.tech/topics/dom.md>), [jQuery](<https://devfeed.tech/topics/jquery.md>)

Tags: [articles](<https://devfeed.tech/tags/articles.md>), [blog](<https://devfeed.tech/tags/blog.md>), [internet-explorer](<https://devfeed.tech/tags/internet-explorer.md>), [internet-explorer-bugs](<https://devfeed.tech/tags/internet-explorer-bugs.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [jquery](<https://devfeed.tech/tags/jquery.md>), [js](<https://devfeed.tech/tags/js.md>), [password](<https://devfeed.tech/tags/password.md>), [security](<https://devfeed.tech/tags/security.md>), [text](<https://devfeed.tech/tags/text.md>), [tips](<https://devfeed.tech/tags/tips.md>), [usability](<https://devfeed.tech/tags/usability.md>), [ux](<https://devfeed.tech/tags/ux.md>)

## AI overview

A discussion of password masking, usability, and security tradeoffs, arguing that passwords should remain masked by default while users can opt to reveal entered characters. It also explains a JavaScript implementation and compatibility problems with changing input types in Internet Explorer.

## Source excerpt

I just read Jakob Nielsen's recent post in which he urged web designers/developers to stop password masking due to it's inherent usability issues. I found it an interesting read. Hey, at last, someone dared to talk about the elephant in the room! In most cases password masking is indeed useless, but still, there are several cases where you need that kind of protection. He also points that out, suggesting a checkbox to enable the user to mask their entered password if they wish to do so. He also suggests that checkbox being enabled by default on sites that require high security. I think the checkbox idea is really good, as long as it works in the opposite way: Password masking should always be the default and you should check the checkbox to show the characters you typed. This is in line with what Windows (Vista or newer) users are already accustomed to anyway: This can (and should) be done with JavaScript alone: if the user has it turned off, no problem, just a regular old password field. Of course the checkbox should also be dynamically added, to prevent users with disabled JS from viewing a checkbox that does nothing at all. This seems easy at first, even without a library (although, in this particular case, a library would greatly reduce the amount of code required, so much that I'm tempted to include a jQuery version as well): window.onload = function() { var passwords = document.getElementsByTagName('input'); for(var i=0; i<passwords.length; i++) { if(passwords\[i\].type == 'password') { var password = passwords\[i\]; var showCharsCheckbox = document.createElement('input'); showCharsCheckbox.type = 'checkbox'; showCharsCheckbox.onclick = (function(input) { return function() { input.type = this.checked? 'text' : 'password'; }; })(password); var showCharsLabel = document.createElement('label'); showCharsLabel.appendChild(showCharsCheckbox); showCharsLabel.appendChild(document.createTextNode('Show characters')); // If the password field is inside a <label> element