手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >html文本框提示效果的示例代码
html文本框提示效果的示例代码
摘要:完整代码如下:复制代码代码如下:html文本框提示效果*{margin:0px;padding:0px;font-size:12px;}in...

完整代码如下:

复制代码 代码如下:

<!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">

*{

margin:0px;padding:0px;font-size:12px;

}

input{

width:100px;height:20px;border:1px solid #ccc;

}

</style>

</head>

<body>

<script language="javascript">

function tips(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"></div>

<br />

姓名:<input type="text" id="username" onfocus="tips('username','姓名长度最多16个字符')" onblur="outtips()" />

<br />

密码:<input type="password" id="password" onfocus="tips('password','密码长度必须在3-18位之间')" onblur="outtips()" />

</body>

</html>

【html文本框提示效果的示例代码】相关文章:

打印/预览/设置的客户端代码

javascript搜索框效果实现方法

Ctrl + Enter提交前检测的代码

Javascript特效:随机显示图片的源代码

光标定位等TextRange的操作的范例代码

jquery实现弹出层效果实例

一些有关检查数据的JS代码

jQuery实现首页图片淡入淡出效果的方法

JavaScript实现鼠标拖动效果的方法

JavaScript实现文本框中默认显示背景图片在获得焦点后消失的方法

精品推荐
分类导航