df
This commit is contained in:
parent
abe27b376d
commit
d8f5b1b18a
|
|
@ -146,9 +146,12 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// On attend que TOUTE la page et les scripts du footer (jQuery) soient chargés
|
||||
window.addEventListener('load', function() {
|
||||
if (typeof jQuery === 'undefined') return;
|
||||
|
||||
// 1. GESTION AFFICHAGE MOT DE PASSE
|
||||
$('.toggle-password').on('click', function() {
|
||||
$('.toggle-password').off('click').on('click', function() {
|
||||
const target = $(this).attr('data-target');
|
||||
const $input = $(target);
|
||||
const $icon = $(this).find('i');
|
||||
|
|
@ -171,7 +174,6 @@
|
|||
const p1 = $nvmdp.val();
|
||||
const p2 = $cfnvmdp.val();
|
||||
|
||||
// Validation simple de correspondance
|
||||
if (p2.length > 0) {
|
||||
if (p1 === p2) {
|
||||
$cfnvmdp.addClass('is-valid').removeClass('is-invalid');
|
||||
|
|
@ -180,32 +182,36 @@
|
|||
$cfnvmdp.addClass('is-invalid').removeClass('is-valid');
|
||||
$btn.prop('disabled', true);
|
||||
}
|
||||
} else {
|
||||
$cfnvmdp.removeClass('is-valid is-invalid');
|
||||
}
|
||||
}
|
||||
|
||||
$nvmdp.on('keyup', checkPass);
|
||||
$cfnvmdp.on('keyup', checkPass);
|
||||
$nvmdp.on('keyup input', checkPass);
|
||||
$cfnvmdp.on('keyup input', checkPass);
|
||||
|
||||
// 3. INTERCEPTION DU FORMULAIRE (LIAISON AVEC VOTRE FONCTION)
|
||||
$('#formChangerPass').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const p1 = $("#nvmdp").val();
|
||||
const p2 = $("#cfnvmdp").val();
|
||||
// 3. INTERCEPTION DU FORMULAIRE
|
||||
const form = document.getElementById('formChangerPass');
|
||||
if (form) {
|
||||
form.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const p1 = $("#nvmdp").val();
|
||||
const p2 = $("#cfnvmdp").val();
|
||||
|
||||
if (p1 !== p2) {
|
||||
// Utilisation de votre alerte bilingue
|
||||
alert_ebene("Les mots de passe ne correspondent pas !", "Passwords do not match!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Si tout est ok, on utilise confirm_ebene avant l'envoi
|
||||
confirm_ebene("Confirmez-vous le changement de mot de passe ?", "Confirm password change?")
|
||||
.then((isConfirmed) => {
|
||||
if (isConfirmed) {
|
||||
this.submit();
|
||||
if (p1 !== p2) {
|
||||
alert_ebene("Les mots de passe ne correspondent pas !", "Passwords do not match!");
|
||||
return false;
|
||||
}
|
||||
|
||||
confirm_ebene("Confirmez-vous le changement de mot de passe ?", "Confirm password change?")
|
||||
.then((isConfirmed) => {
|
||||
if (isConfirmed) {
|
||||
// Utilisation de la méthode native pour éviter de reboucler sur l'event submit
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user