完整代码如下:
复制代码代码如下:
<!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>