Skip to content

Commit c86ded1

Browse files
account save disable
1 parent 06db39f commit c86ded1

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

assets/css/ledenportaal.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@
293293
box-shadow: 0 0 0 3px rgba(0, 145, 213, 0.4);
294294
}
295295

296+
.lp-knop:disabled {
297+
background-color: #b0d4ea;
298+
border-color: #b0d4ea;
299+
cursor: not-allowed;
300+
opacity: 0.7;
301+
}
302+
296303
/* ==========================================================================
297304
Links
298305
========================================================================== */

templates/account-form.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
</p>
292292
<?php endif; ?>
293293
<div class="lp-form-groep lp-form-groep--acties">
294-
<button type="submit" name="lp_account_submit" class="lp-knop">
294+
<button type="submit" name="lp_account_submit" class="lp-knop" id="lp-opslaan-knop" disabled>
295295
<?php esc_html_e( 'Wijzigingen opslaan', 'mijn-ledenportaal' ); ?>
296296
</button>
297297
<a href="<?php echo esc_url( lp_uitlog_url() ); ?>" class="lp-link lp-link--uitloggen">
@@ -302,6 +302,7 @@
302302
</form>
303303
<script>
304304
(function() {
305+
// IBAN match check
305306
var iban1 = document.getElementById('lp-iban');
306307
var iban2 = document.getElementById('lp-iban2');
307308
var melding = iban2 ? iban2.closest('.lp-form-groep').querySelector('.lp-iban-match-melding') : null;
@@ -311,6 +312,34 @@ function checkIban() {
311312
}
312313
if (iban1) iban1.addEventListener('input', checkIban);
313314
if (iban2) iban2.addEventListener('input', checkIban);
315+
316+
// Knop inschakelen bij wijziging
317+
var form = document.getElementById('lp-account-form');
318+
var knop = document.getElementById('lp-opslaan-knop');
319+
if (!form || !knop) return;
320+
321+
var snapshot = {};
322+
form.querySelectorAll('input:not([disabled]), select, textarea').forEach(function(el) {
323+
var key = el.name + '||' + el.type;
324+
if (el.type === 'checkbox' || el.type === 'radio') {
325+
snapshot[key] = el.checked;
326+
} else {
327+
snapshot[key] = el.value;
328+
}
329+
});
330+
331+
function isGewijzigd() {
332+
var gewijzigd = false;
333+
form.querySelectorAll('input:not([disabled]), select, textarea').forEach(function(el) {
334+
var key = el.name + '||' + el.type;
335+
var huidig = (el.type === 'checkbox' || el.type === 'radio') ? el.checked : el.value;
336+
if (snapshot[key] !== huidig) gewijzigd = true;
337+
});
338+
return gewijzigd;
339+
}
340+
341+
form.addEventListener('input', function() { knop.disabled = !isGewijzigd(); });
342+
form.addEventListener('change', function() { knop.disabled = !isGewijzigd(); });
314343
})();
315344
</script>
316345

0 commit comments

Comments
 (0)