input text 框当密码框使用(火狐下有默认值的bug)

简介:
<!DOCTYPE html>
<html>


<head>
<meta charset="utf-8" />
<title> </title>
<meta content="initial-scale=1.0,maximum-scale=1.0,width=device-width" name="viewport">
<meta name="apple-touch-fullscreen" content="YES">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<link rel="stylesheet" href="css/reset.css" />
<style type="text/css">
#main {
border: 1px solid red;
width: 90%;
height: 100%;
margin: 0 auto;
}
.hearder {
margin: 20px 0px;
font-size: 14px;
font-weight: bold;
color: red;
}
.dd {
color: red;
width: 200px;
height: 100px;
text-align: right;
}
input {
width: 200px;
height: 50px;
margin: 0 20px;
}
</style>
</head>


<body>
<input type="text" id="Password1" name="Password1" value="密码(6-16位字母数字组合)" maxlength="30" />
<input type="text" name="password2" id="Password2" value="确认密码" />
<script type="text/javascript">
$('#Password1').on('focus',function(){
if($(this).val()=='密码(6-16位字母数字组合)'){
$(this).val('');
$(this).attr('type','password');

}
    });
  $('#Password1').on('blur',function(){
if($(this).val()==''){
$(this).val('密码(6-16位字母数字组合)');
$(this).attr('type','text');
}
    });
    $('#Password2').on('focus',function(){
if($(this).val()=='确认密码'){
$(this).val('');
$(this).attr('type','password');
}
    });
  $('#Password2').on('blur',function(){
if($(this).val()==''){
$(this).val('确认密码');
$(this).attr('type','text');
}
    });
</script>
</body>


</html>






解决办法就是:在前面加input 元素,只有第一个有默认值

目录
相关文章
|
6天前
【UI】 修改element-ui input输入框placeholder提示信息、占位符的样式
【UI】 修改element-ui input输入框placeholder提示信息、占位符的样式
12 0
|
7月前
|
移动开发 HTML5
修改HTML5 input placeholder 颜色及修改失效的解决办法
修改HTML5 input placeholder 颜色及修改失效的解决办法
|
8月前
|
前端开发
使用 div 实现 input、textarea 输入框,并支持 placeholder 属性(解决浏览器兼容问题)
使用 div 实现 input、textarea 输入框,并支持 placeholder 属性(解决浏览器兼容问题)
108 0
|
Windows
el-input在ie浏览器下readonly属性出现光标
el-input在ie浏览器下readonly属性出现光标
135 0
|
Web App开发 前端开发
去掉谷歌默认的input textarea边框样式
谷歌浏览器Chrome基于WebKit开源浏览器引擎,自然能够通过相关的一切方法自定义设置浏览器的默认状态。谷歌浏览器Chrome安装之后,大家应该都留意到所有的表单都会添加黄色边框特效。在某些时候这些特效还是很不错的,但是当网站本身就已经对于表单样式有一定的设计时,这种默认表单样式就会让人觉得套样了!
119 0
|
iOS开发
iOS开发 - 设置placeholder无效?
iOS开发 - 设置placeholder无效?
120 0
|
前端开发 索引
PythonGUI编程(3) ---- Options选项 Entry单行文本框 Text多行文本框
PythonGUI编程(3) ---- Options选项 Entry单行文本框 Text多行文本框
185 0
PythonGUI编程(3) ---- Options选项 Entry单行文本框 Text多行文本框
|
Web App开发 iOS开发
Bug: Safari浏览器input框placeholder和内容都不显示
Bug: Safari浏览器input框placeholder和内容都不显示
238 0
|
移动开发 前端开发
火狐谷歌浏览器去掉input type=number时控件的方法
火狐谷歌浏览器去掉input type=number时控件的方法
常用input输入框的行内验证
只能输入正整数 <input type="text" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.
1342 0