我正在使用用户名和密码创建登录页面。我使用“input type =”password“”创建了密码字段作为星号,但是我希望在显示原始字符之前一秒钟后显示星号。如何在html中显示密码字段为第二个星号后
3
A
回答
3
你可以使用这个插件,它与所有设备兼容。 https://blog.decaf.de/2009/07/07/iphone-like-password-fields-using-jquery/
这里是另一种解决方案,但是这个不会隐藏最后一个字符,除非你从字段模糊。 http://www.sitepoint.com/better-passwords-1-the-masked-password-field/
//apply masking to the demo-field
//pass the field reference, masking symbol, and character limit
new MaskedPassword(document.getElementById("demo-field"), '\u25CF');
//test the submitted value
document.getElementById('demo-form').onsubmit = function(){
\t alert('pword = "' + this.pword.value + '"');
\t return false;
};
<script src="http://www.sitepoint.com/examples/password/MaskedPassword/MaskedPassword.js"></script>
<form id="demo-form" action="#">
<fieldset>
<label for="demo-field"><strong>This is a masked-password field.</strong> Type into the field to see the masking effect:</label>
<span style="position: relative;">
<input type="hidden" name="pword" value="sasasas">
<input class="password masked" id="demo-field" value="" type="text" autocomplete="off">
</span>
</fieldset>
</form>
0
您需要使用text
类型的input
领域开始。后来在setTimeout
,您可以更改类型password
,如下图所示:
HTML:
<label>Password</label>
<input type="text" name="password" value="[email protected]" />
JS:
setTimeout(function() {
document.getElementsByTagName('input')[0].type = "password"
}, 1000);
请参考这里的demo。
0
在jQuery中使用setTimeout
您可以将attr
从type=text
更改为password
。但这不是一个好方法。
您可以使用如下所示使用mouse-over/mouse-out
。
$(document).ready(function(){
$("#method2").mouseover(function(){
this.type = "text";
}).mouseout(function(){
this.type = "password";
})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<input type="password" id="method2" value="" placeholder="Type in your password" /> Event using mouseover and mouseout
你也可以做旧的方式:
//Place this plugin snippet into another file in your applicationb
(function ($) {
$.toggleShowPassword = function (options) {
var settings = $.extend({
field: "#password",
control: "#toggle_show_password",
}, options);
var control = $(settings.control);
var field = $(settings.field)
control.bind('click', function() {
if (control.is(':checked')) {
field.attr('type', 'text');
} else {
field.attr('type', 'password');
}
})
};
}(jQuery));
//Here how to call above plugin from everywhere in your application document body
$.toggleShowPassword({
field: '#test1',
control: '#test2'
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Password:
<input type="password" id="test1" value="" placeholder="Type your password" />
<input id="test2" type="checkbox" />Show password
来源:fiddle
相关问题
- 1. 显示星号而不是密码字段中的值
- 2. 如何显示Wordpress自定义字段后的第二段落
- 3. 如何将密码字段更改为星号而不是点
- 4. 第一个字段中的文本显示为第二个字段的标签
- 5. 使用星号隐藏密码字段
- 6. 更改显示的HTML密码字段的符号
- 7. 如何在ZF 1中显示两个密码字段?
- 8. 在一周后显示在第一个字段中输入日期的第二个字段中的日期
- 9. 我如何在我的python程序中输入密码以显示为星号
- 10. 如何在生成随机密码时以星号格式显示密码
- 11. 如何有密码回荡为星号
- 12. 如何在密码输入时将密码转换为星号?
- 13. 显示密码字段只
- 14. 如何显示第二个显示器
- 15. 如何更改Qml TextField echoMode密码显示星号?
- 16. 如何使TextBox成为“密码框”并在使用MVVM时显示星号?
- 17. 如何修改LabelFor以在必填字段上显示星号?
- 18. 如何在html中显示textarea字段?
- 19. 字(密码)以星号显示 - 控制台应用程序
- 20. 如何防止Satchmo表单在必填字段后面显示星号?
- 21. 为什么IE8在HTML密码字段中显示问号而不是项目符号?
- 22. 将文本框值转换为星号符号,如密码编辑字段
- 23. 如何在密码字段中删除并显示单词“password”
- 24. 如何使用CLion在C++中显示用于输入密码的星号
- 25. 如何在java中使密码成为星号
- 26. 字符串到星号,掩码密码
- 27. Angularjs显示字段为html
- 28. 使用gcc替换密码字段中的星号
- 29. 将密码文本转换为星号后放一个空格
- 30. 如何使用Jquery的Coolinput在密码字段中显示提示“输入密码”,但在用户键入时使用星号隐藏输入?
你为什么要这么做?一些移动设备(即在Android上)已经在'type =“password”'的输入字段中默认执行此操作。 – yjwong
我想在我的HTML网页中实现此功能 –