I have this code to verify data (password) on both the fields whether it is equal.
When I enter the password in the first field and go to second field to re-enter the password I get the error cross (fa-close) at that time.
Instead I need that after I get out of second field, after that I get the error message.
HTML:
<input type="password" name="password" id="password" /><br>
<input type="password" name="password2" id="password2" onKeyUp="checkPass(); return false;" />
<span id="confirmMessage" class="confirmMessage"></span>
Here is my javascript code:
<script type="text/javascript">
function checkPass() {
var pass1 = document.getElementById('password');
var pass2 = document.getElementById('password2');
var message = document.getElementById('confirmMessage');
var goodColor = "#fff";
var goodColored = "#087a08";
var badColor = "#fff";
var badColored = "#ed0b0b";
if(password.value == password2.value) {
password2.style.backgroundColor = goodColor;
message.style.color = goodColored;
message.innerHTML = "<i class='fa fa-check'></i>"
}
else {
password2.style.backgroundColor = badColor;
message.style.color = badColored;
message.innerHTML = "<i class='fa fa-close'></i>"
}
}
</script>
Help will be appreciated. Thank you.