Gunnar Bittersmann: Formular mit Value und Passwort

Beitrag lesen

@@Beat:

nuqneH

Dein Problem würde sich in nichts auflösen, wenn du dem Input-Feld ein Label Element beigesellen würdest.

Welches sich auch gleich nutzen lässt, um hinter (in z-Richtung) dem Eingabefeld dargestellt zu werden:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
  <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>  
    <title>TEST</title>  
    <script type="text/javascript">[code lang=javascript]document.documentElement.className += " js";
~~~</script>  
    <style type="text/css">  
~~~css
.js label  
{  
  color: #666;  
  position: absolute;  
  text-indent: .2em;  
}

</style>
  </head>
  <body>
    <label for="passwordinput">Passwort</label>
    <input id="passwordinput" type="password"/>
    <script type="text/javascript">
//[code lang=xml]<![CDATA[
var passwordinput = document.getElementById("passwordinput");
passwordinput.label = passwordinput.previousSibling.nodeType == 3 ? passwordinput.previousSibling.previousSibling : passwordinput.previousSibling;
passwordinput.onfocus = function ()
{
  this.label.style.display = "none";
};
passwordinput.onblur = function ()
{
  this.label.style.display = this.value ? "none" : "block";
};
//]]>[/code]
    </script>
  </body>
</html>[/code]

Qapla'

--
Alle Menschen sind klug. Die einen vorher, die anderen nachher. (John Steinbeck)