我在表单上有以下输入:
<input class="password" type="password" title="Your Password" name="password" size="30" autocomplete="off" value="" >
<input class="confirmpass" type="password" title="Confirm Password" name="pass_confirm" size="30" autocomplete="off" value="" >
<div class="jresults" align="left" style="display:none;" id="confirmdata"></div>
<input class="showpassword" type="checkbox" title="Show Passwords">
这是显示密码功能:
//Show password function
$(".showpassword").click(function()
{
var change = $(this).is(":checked") ? "text" : "password";
var password = $("input.password");
var showpass = $("<input type='" + change + "' />")
.attr("id", password.attr("id"))
.attr("title", password.attr("title"))
.attr("name", password.attr("name"))
.attr("size", password.attr("size"))
.attr('class', password.attr('class'))
.val(password.val())
.insertBefore(password);
password.remove();
password = showpass;
var confirmpass = $("input.confirmpass");
var showconfirm = $("<input type='" + change + "' />")
.attr("id", confirmpass.attr("id"))
.attr("title", confirmpass.attr("title"))
.attr("name", confirmpass.attr("name"))
.attr("size", confirmpass.attr("size"))
.attr('class',confirmpass.attr('class'))
.val(confirmpass.val())
.insertBefore(confirmpass);
confirmpass.remove();
confirmpass = showconfirm;
});
这是确认密码匹配功能:
//match passwords entered
$('.confirmpass').blur(function()
{
var Pass = $('.password').val();
var cPass = $('.confirmpass').val();
$('#confirmdata').css("display","none");
if(cPass.length>5)
{
if (Pass != cPass)
{
$('#confirmdata').css("display","block");
$('#confirmdata').css("color","#ff0000");
$('#confirmdata').html("No Match");
$("input.confirmpass").focus();
return;
}
$('#confirmdata').css("display","block");
$('#confirmdata').css("color","#00BB00");
$('#confirmdata').html("Matched");
}
});
问题:
如果密码不匹配并且我更正了它们,则模糊上的确认密码将按预期再次运行.....这是正确的
现在,如果密码不匹配并且我单击复选框以显示密码然后更正,则确认密码将不会在模糊时再次运行。
谁能看到可能导致这种情况的原因?