完整代码如下:
复制代码代码如下:
<!doctype html public " - // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
<head>
<Title> HTML </title>
<style type = "text/css">
*{
マージン:0px;パディング:0px; font-size:12px;
}
入力{
幅:100px;高さ:20px;境界線:1pxソリッド#ccc;
}
</style>
</head>
<body>
<スクリプト言語= "javascript">
関数のヒント(id、str){
var l = document.getElementById(ID).OffsetLeft+120;
var t = document.getElementById(id).offsettop;
document.getElementById( "Tips")。innerhtml = "提示:"+str;
document.getElementById( "Tips")。style.left = l+"px";
document.getElementById( "Tips")。style.top = t+"px";
document.getElementById( "Tips")。style.display = "";
}
function outtips(){
document.getElementById( "Tips")。style.display = 'none';
}
</script>
<div id = "tips" style = "position:absolute; border:1px solid #ccc; padding:0px 3px; color:#f00; display:none; height:20px; line-height:20px; background:#fcfcfc"> </div>
<br />
and:<入力タイプ= "text" id = "username" onfocus = "tips( 'username'、 '姓名长度最多16个字符')" onblur = "outtips()" />
<br />
and:<入力タイプ= "パスワード" id = "password" onfocus = "Tips( 'password'、 '密码长度必须在3-18位之间')" onblur = "outtips()" />
</body>
</html>