Iam building a page that contains in it a username and a password...
The username and password fields start as type="text" and of " E-mail or Username" and " Password" values.
When a user clicks on the username(Onfocus), its value changes to "" and the field is focused to be written in. On the other hand, if the user keeps the field empty "" (onblur) the field changes back to " E-mail or Username".. This has worked fine with me as you can see in the script.
When a user clicks on password(Onfocus), it calls a function that changes the innerHTML of a the span containing the password's field... the password field changes type to "Password" and is empty and focused ready to be written at.... NOW... I want that if the value of the password field is left empty "", I want it to change type back to "text" and take the value " Password"... I did it but it is not working with me... I appreciate any help...
The script is:
<script language="javascript">
function changetopassword(){
if(document.signin.password.value==" Password"){
document.getElementById("spanpassword").innerHTML= "<input type=\"password\" name=\"password\" class=\"signin\" id=\"newpasswordfield\" />" ;
document.signin.password.focus()
document.signin.password.focus()
}
}
function changetotext() {
if(document.signin.password.value==""){
document.getElementById("spanpassword").innerHTML= "<input type=\"text\" name=\"password\" class=\"signin\" value=\" Password\"/>"
}
}
</script>
<form name="signin" method="POST" style="padding: 0; margin-top: 0px; ,margin-bottom: 0px">
<input type="text" name="username" value=" E-mail or Username" class="signin" onFocus="if(this.value == ' E-mail or Username') this.value='';" onblur=" if (this.value=='')this.value=' E-mail or Username';">
<br style="line-height: 5px">
<span id="spanpassword"><input type="text" name="password" value=" Password" class="signin" onFocus="changetopassword('spanpassword');" onblur="changetotext('spanpassword')"> </span>
<input type="image" src="images/home/signin.jpg" align="middle" style="margin-left:14px " width="47" height="18">
</form>