Make passwords visible (Technics)

by Arnd @, Saturday, April 11, 2009, 20:40 (5465 days ago)

Hi,

<input type="password"> is only useful if somebody might be looking over your shoulder.
If nobody does, it's more user-friendly to echo the password legible.

What about this:



<input id="password" type="password" name="userpw" size="25" /><span id="pw_show">&nbsp;</span>
<script type="text/javascript">/* <![CDATA[ */
function on_off(pa)
{literal}{{/literal}
  if (pa.checked) document.forms[1].elements["password"].type="text";
   else document.forms[1].elements["password"].type="password";
{literal}}{/literal}

if (!(/MSIE/.test(navigator.userAgent)))
{literal}{{/literal}
 var sh_inner='<input type="checkbox" name="show_pw" id="show_pw" onclick="on_off(this);" /><label for="show_pw">Passwort sichtbar machen</label>';
 document.getElementById("pw_show").innerHTML=sh_inner;
{literal}}{/literal}

/* ]]> */</script>

Didn't work in IE so I blocked that "browser" from this function. (Any JS experts?)

See that in action at Schreibkunst

Arnd

Avatar

Make passwords visible

by Micha ⌂, Monday, April 13, 2009, 11:10 (5464 days ago) @ Arnd

Hi,

Didn't work in IE so I blocked that "browser" from this function.

You don't block it cocksure.

The type-attribute is set to readonly, therefore, it works correct in IE. A work-around to set/overwrite the type-attribute is the following:

 
var inp = null;
try {
 inp = document.createElement("input");
 inp.type = "password";
}
catch(err) {
 inp = document.createElement('<input type="password">');
}

regards Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

RSS Feed of thread