View Single Post
Old 02-09-2007, 11:01 AM   PM User | #1
jackl79
New to the CF scene

 
Join Date: Feb 2007
Location: London
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
jackl79 is an unknown quantity at this point
Exclamation Change input type="text" to input type="password"

I need to change input type="text" to input type="password" via JavaScript

Code:
<form id="login" action="#" method="post">
<input id="username-field" type="text" name="username" title="Username" onmousedown="javascript:this.value=''; javascript:this.focus();" value="Username" tabindex="1" />
<input id="password-field" type="text" name="password" title="Password" onmousedown="javascript:this.value=''; javascript:this.type='password'; javascript:this.focus();" value="Password" tabindex="2" />
<input type="submit" name="submit" value="sign in" tabindex="3" />
</form>
This works in Firefox and Safari but not IE So then I tried this code

Code:
<script type="text/javascript">
function passit(ip){
var np=ip.cloneNode(true);
np.type='password';
if(np.value!=ip.value)
np.value=ip.value;
ip.parentNode.replaceChild(np,ip);
}
</script>

<form id="login" action="#" method="post">
<input id="username-field" type="text" name="username" title="Username" onmousedown="javascript:this.value=''; javascript:this.focus();" value="Username" tabindex="1" />
<input id="password-field" type="text" name="password" title="Password" onmousedown="javascript:this.value=''; passit(this.form[0]); javascript:this.focus();" value="Password" tabindex="2" />
<input type="submit" name="submit" value="sign in" tabindex="3" />
</form>
This does what I need but turns the username type to password field not the password box

Please can somone help!
jackl79 is offline   Reply With Quote