完整代碼如下:
複製代碼代碼如下:
<! Doctype HTML公共“ - // W3C // DTD XHTML 1.0 Transitional // en”“” http://www.org/tr/tr/xhtml1/dtd/xhtml1-xhtml1-transitional.transitional.dtdd'>
<html xmlns =“ http://www.w3.org/1999/xhtml” xml:lang =“ en” en'lang =“ en”>
<頭>
<title> html </title>
<style type =“ text/css”>
*{
保證金:0px;填充:0px;字體大小:12px;
}
輸入{
寬度:100px;高度:20px;邊框:1px實心#CCC;
}
</style>
</head>
<身體>
<腳本語言=“ 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 =“”;
}
函數outtips(){
document.getElementById(“ tips”)。 style.display ='none';
}
</script>
<div id =“ tips” style =“位置:絕對;邊框:1px固體#ccc; padding:0px 3px; color:#f00; display:none; height; height; height; 20px; line-height:20px;背景:#fcfcfc:#fcfcfc“> </div>> </div>
<br />
:<input type =“ text” id =“用戶名” onfocus =“ tips('用戶名','姓名長度最多16個字符')“ onblur =” outtips() />
<br />
密碼:<input type =“密碼” id =“ password” onfocus =“提示('密碼','密碼長度必須在3-18位之間')” onblur =“ outtips()” />
</body>
</html>