Jul 2nd - Fix Edit user password error

This commit is contained in:
2026-07-02 09:34:11 -04:00
parent ea04afe398
commit 7d94cfd016
2 changed files with 37 additions and 2 deletions
+30 -1
View File
@@ -44,7 +44,11 @@
<div class="col-12"><hr style="border-color:var(--border);"/></div>
<div class="col-md-6">
<label class="form-label">New Password <span style="color:var(--muted);font-weight:400;">(optional)</span></label>
<input type="password" class="form-control" name="new_password" placeholder="Leave blank to keep current"/>
<input type="password" class="form-control" id="new-password" name="new_password" placeholder="Leave blank to keep current"/>
</div>
<div class="col-md-6">
<label class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="confirm-password" name="confirm_password" placeholder="Repeat new password"/>
</div>
</div>
<div class="d-flex gap-2 mt-4">
@@ -57,3 +61,28 @@
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
document.querySelector('form').addEventListener('submit', function (e) {
const pw = document.getElementById('new-password').value;
const pw2 = document.getElementById('confirm-password').value;
if (pw !== pw2) {
e.preventDefault();
document.getElementById('confirm-password').style.borderColor = 'var(--danger)';
const msg = document.createElement('div');
msg.style.cssText = 'font-size:12px;color:var(--danger);margin-top:4px;';
msg.textContent = 'Passwords do not match.';
const existing = document.getElementById('pw-match-msg');
if (existing) existing.remove();
msg.id = 'pw-match-msg';
document.getElementById('confirm-password').insertAdjacentElement('afterend', msg);
}
});
document.getElementById('confirm-password').addEventListener('input', function () {
this.style.borderColor = '';
const msg = document.getElementById('pw-match-msg');
if (msg) msg.remove();
});
</script>
{% endblock %}