Posts Tagged ‘Javascirpt’

Display password javascript

February 15, 2008

When I read The Dramatic Password Reveal

I decided to wrote display password mode by javascript.

Here it is.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

<script type=’text/javascript’>

function DisplayPassword()
{
var chk = document.getElementById(‘chkPassword’);
var PWD=document.getElementById(‘PWD’);
var tPWD=document.getElementById(‘tPWD’);
if(chk.checked)
{
tPWD.style.display=’block’;
PWD.style.display=’none’;
}
else
{
tPWD.style.display=’none’;
PWD.style.display=’block’;
}

}
function ChangeValue(v)
{
var PWD=document.getElementById(‘PWD’);
var tPWD=document.getElementById(‘tPWD’);
if(v==’1′)
{
tPWD.value = PWD.value;
}
else
{
PWD.value = tPWD.value;
}
}
</script>
</HEAD>

<BODY>
<INPUT TYPE=”password” id=”PWD” onkeyup=’ChangeValue(1);’>
<INPUT TYPE=’text’ id=”tPWD” onkeyup =’ChangeValue(2);’>
<br>
<INPUT TYPE=”checkbox” NAME=”” id=”chkPassword” onclick=”DisplayPassword();” value=”Show Password”>
<script type=’text/javascript’>
document.getElementById(‘tPWD’).style.display=’none’;
</script>
</BODY>
</HTML>

display-pass.png