yuelong 发表于 2013-2-7 16:56:25

HTML DOM select() 方法

定义和用法
select() 方法用于选取密码域中的文本。
语法
passwordObject.select()
实例
下面的例子可选取密码域中的文本:
<html>
<head>
<script type="text/javascript">
function selText()
  {
  document.getElementById('password1').select()
  }
</script>
</head>
<body>
<form>
<input type="password" id="password1" value="thgrt456" />
<input type="button"value="Select text" />
</form>
</body>
</html>
参考:http://www.w3school.com.cn/htmldom/met_password_select.asp
 
 
实战用法:当用户没有输入密码、密码格式错误的时候,给出提示
if(document.forms.password.value==null || document.forms.password.value==""){
  alert("提示:请输入密码。");
  document.forms.password.select();
  return false;
 }
页: [1]
查看完整版本: HTML DOM select() 方法