我在MVC5中使用密码HTML帮助程序隐藏输入的社会安全号码。
@Html.Password("s", null, new { @maxlength = 9, autocomplete = "off" })
我看到它的问题是你只需在键入时看到点。是否有任何方法可以修改帮助程序行为以显示您输入的字符一两秒然后将它们转换为点?该行为将让用户确认他们正在输入正确的字符。如果无法修改帮助行为,还有另一种方法可以实现吗?
答案 0 :(得分:0)
我发现这个小提琴可能你可以用它作为选项
$(function(){
$(".showpassword").each(function(index,input) {
var $input = $(input);
$('<label class="showpasswordlabel"/>').append(
$("<input type='checkbox' class='showpasswordcheckbox' />").click(function() {
var change = $(this).is(":checked") ? "text" : "password";
var rep = $("<input type='" + change + "' />")
.attr("id", $input.attr("id"))
.attr("name", $input.attr("name"))
.attr('class', $input.attr('class'))
.val($input.val())
.insertBefore($input);
$input.remove();
$input = rep;
})
).append($("<span/>").text("Show password")).insertAfter($input);
});
});