完整代码如下 :
复制代码代码如下::
<! DocType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transsitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml: Lang = "en" Lang = "en">
<kopf>
<title> html 文本框提示效果 </title>
<style type = "text/css">
*{{
Rand: 0px; Padding: 0px; Schriftgröße: 12px;
}
Eingang{
Breite: 100px; Höhe: 20px; Rand: 1px fest #CCC;
}
</style>
</head>
<body>
<script Language = "JavaScript">
Funktionstipps (id, str) {
var l = document.getElementById (ID) .OffsetLeft+120;
var t = document.getElementById (id) .Offsettop;
document.getElementById ("Tipps"). Innerhtml = "提示 :"+str;
document.getElementById ("tipps"). style.left = l+"px";
document.getElementById ("tipps"). style.top = t+"px";
document.getElementById ("tipps"). style.display = "";
}
Funktion outtips () {
document.getElementById ("tipps"). style.display = 'none';
}
</script>
<div id = "tips" style = "Position: absolut; Rand: 1px solide #CCC; Padding: 0px 3px; Farbe:#f00; Anzeige: Keine; Höhe: 20px; Zeilenhöhe: 20px; Hintergrund: #fcfcfc"> </div>
<br />
姓名 : <Eingabe type = "text" id = "userername" onfocus = "tipps ('userername', '姓名长度最多 16 个字符')" onblur = "outtips ()" />
<br />
密码 : <Eingabe type = "Passwort" id = "Passwort" onfocus = "Tipps ('Passwort', '密码长度必须在 3-18 位之间')" onblur = "outtips ()" />
</body>
</html>