Pues a mi no me funciona, te adjunto el código:
Código javascript
:
Ver original<script type="text/javascript">
function checkevent(e)
{
var obj=e.srcElement || e.target;
var objeto = document.getElementById(obj.name);
var evento = e.type;
if ( obj.name == "email" )
{
if(evento == "focus" && objeto.value == "tu email")
{ objeto.value = ""; }
if(evento == "blur" && objeto.value == "" )
{ objeto.value = "tu email"; }
}
if ( obj.name == "pass" )
{
var formulario = document.getElementById("identificacion");
if(evento == "focus" && objeto.value == "tu contraseña")
{
var nuevotextbox = document.createElement("input");
nuevotextbox.setAttribute("id", "pass");
nuevotextbox.setAttribute("name", "pass");
nuevotextbox.setAttribute("type", "password");
nuevotextbox.setAttribute("value", "");
if (nuevotextbox.addEventListener)
{nuevotextbox.addEventListener('focus', function(event) { checkevent(event) }, false);}
else
{nuevotextbox.attachEvent('onfocus', function(event) { checkevent(event) });}
formulario.replaceChild(nuevotextbox, objeto);
setTimeout(function(){ nuevotextbox.focus()}, 100);
}
if(evento == "blur" && objeto.value == "")
{
var nuevotextbox = document.createElement("input");
nuevotextbox.setAttribute("id", "pass");
nuevotextbox.setAttribute("name", "pass");
nuevotextbox.setAttribute("type", "text");
nuevotextbox.setAttribute("value", "tu contraseña");
if (nuevotextbox.addEventListener)
{nuevotextbox.addEventListener('blur', function(event) { checkevent(event) }, false);}
else
{nuevotextbox.attachEvent('onblur', function(event) { checkevent(event) });}
formulario.replaceChild(nuevotextbox, objeto);
}
}
}
</script>
Código html:
Ver original<form id="identificacion" action="index.php" method="post" enctype="application/x-www-form-urlencoded"> <input id="email" type="text" name="email" title="Email de usuario" value="tu email" size="20" onfocus="checkevent(event)" onblur="checkevent(event)" /> <input id="pass" type="text" name="pass" value="tu contraseña" size="10" onfocus="checkevent(event)" onblur="checkevent(event)" /> <input type="submit" value="Ok" />