good evening everybody
i just wanna ask if somebody could help me with problem.
when registering a new user i just wanna add a checkbox beside a password field so that in case the user forgot the content of the password he/she can view it easily by this feature.
when checkbox clicked = show plain text.
when checkbox no clicked = show password field character.
thanks.
show/hide plain text of password field when checkbox clicked
Moderator: General Moderators
- DigitalMind
- Forum Contributor
- Posts: 152
- Joined: Mon Sep 27, 2010 2:27 am
- Location: Ukraine, Kharkov
Re: show/hide plain text of password field when checkbox cli
Hi!
Code: Select all
<html>
<head>
<script type="text/javascript">
<!--
function ShowHide() {
if (document.getElementById('radio1').checked) {
document.getElementById('secret').type = 'text';
} else {
document.getElementById('secret').type = 'password';
}
}
//-->
</script>
</head>
<body>
<form id="form1">
<input type="password" id="secret"><br>
<label><input type="radio" id="radio1" name="radio1" value="on" onchange="ShowHide();">Show</label>
<label><input type="radio" id="radio2" name="radio1" value="off" onchange="ShowHide();" checked>Hide</label>
</form>
</body>
</html>
Re: show/hide plain text of password field when checkbox cli
Changing the type of an input field with JavaScript does not work in all browsers (I think IE is the problem).
I don't have the link anymore but someone had solved it by deleting the input element and replacing it with a new one with the desired type.
I don't have the link anymore but someone had solved it by deleting the input element and replacing it with a new one with the desired type.