Password value on click is not changing the text to 'Password'
Posted
by Sam
on Stack Overflow
See other posts from Stack Overflow
or by Sam
Published on 2010-06-07T10:58:41Z
Indexed on
2010/06/07
11:02 UTC
Read the original article
Hit count: 198
jQuery
window.onload=function() {
var password = document.getElementById('apassword');
var real = document.getElementById('password');
var fake = document.createElement('input');
fake.setAttribute('type', 'text');
/*fake.setAttribute('id', 'password');*/
fake.setAttribute('class', 'contact-input contact-right');
password.appendChild(fake);
fake.setAttribute('value', 'Password');
fake.onfocus = function() {this.style.display='none';real.style.display='';
real.focus();};
real.style.display = 'none';
real.setAttribute('value', '');
real.onblur = function() {if(this.value==''){this.style.display='none';fake.style.display=''}};
};
AND
<label id="apassword">
<input type="password" title="Password" id="password" class="contact-input contact-right" name="password" />
</label>
What is supposed to happen is that when you click on the input box, it changes from 'Password' to a blank type="password" input box, however it doesn't happen. This originally worked, but then I had to change some ID's and classes etc. I'm not sure how to debug scripts, so hopefully someone can help me with that, and also with my question :).
Thankyou :).
© Stack Overflow or respective owner