У меня есть регистрационная форма. Он успешно проверяет значение ввода пароля и ввод пароля подтверждения. (X изменится на ✔️, если оба пароля совпадают) Дело в том, что после появления галочки это выглядит так, будто она застряла там! когда я меняю пароль, флажок должен измениться на X, но это не так! Это застряло на ✔️!
<div id="confirm_pass2">
<span id="password_confirmation" class="unconfirmed_pass"></span>
</div>
<script>
var confirmation = document.getElementById("confirm_password");
confirmation.onfocus = function (){
document.getElementById("confirm_pass2").style.display = "block";
}
confirmation.onblur = function (){
document.getElementById("confirm_pass2").style.display = "none";
}
confirmation.onkeyup = function () {
if (document.getElementById("confirm_password").value.match(document.getElementById("password").value)){
document.getElementById("password_confirmation").classList.remove("unconfirmed_pass");
document.getElementById("password_confirmation").classList.add("confirmed_pass");
} }
</script>
<style>
#confirm_pass2 {
position: absolute;
display: none;
}
.confirmed_pass:before {
position: absolute;
font-size: 25px;
right: 642px;
bottom: 197px;
font-weight: bold;
color: green;
content: "✔";
}
.unconfirmed_pass:before {
font-family: calibri;
position: absolute;
right: 647px;
bottom: 205px;
font-size: 22px;
font-weight: bold;
color: red;
content: "X";
}
</style>
ОБНОВЛЕНИЕ Я изменил "match" на ==, и все, кажется, работает нормально.
if (document.getElementById("confirm_password").value == document.getElementById("password_new").value){...