$(document).on('click', '#show-password-button', function() { $(this).toggleClass("show-password"); var input = $("#password"); input.attr('type') === 'password' ? input.attr('type','text') : input.attr('type','password'); }); $(document).on('click', '#show-confirm-password-button', function() { $(this).toggleClass("show-password"); var input = $("#password2"); input.attr('type') === 'password' ? input.attr('type','text') : input.attr('type','password'); }); function setPassword(event) { const password = $('#password').val().trim(); const password2 = $('#password2').val().trim(); let error = false; if (password.length === 0) { error = true; $('#passwordResetErrorText').html(MSG_PASSWORD_RESET_PASSWORD_EMPTY); } else if (password2.length === 0) { error = true; $('#passwordResetErrorText').html(MSG_PASSWORD_RESET_CONFIRM_PASSWORD_EMPTY); } else if (password !== password2) { error = true; $('#passwordResetErrorText').html(MSG_PASSWORD_RESET_PASSWORD_MISMATCH); } if (error) { $('.loginerrors').addClass('d-none'); $('#passwordResetErrorDiv').removeClass('d-none'); event.preventDefault(); return false; } return true; }