Init Git Prod Mars 2026
This commit is contained in:
commit
d81efe93b1
362 files changed
+86627
No files matched your search
@@ -0,0 +1,81 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const emailInput = document.getElementById("email");
|
||||
const erreurEmail = document.getElementById("email-erreur");
|
||||
const form = document.getElementById("form-inscription");
|
||||
let emailEstValide = true;
|
||||
|
||||
// Vérif e-mail AJAX
|
||||
emailInput.addEventListener("input", function () {
|
||||
const email = emailInput.value;
|
||||
|
||||
if (!email.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)) {
|
||||
erreurEmail.style.display = "none";
|
||||
emailEstValide = false;
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("verifier_email.php", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: "email=" + encodeURIComponent(email)
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
if (data === "existe") {
|
||||
erreurEmail.style.display = "block";
|
||||
emailEstValide = false;
|
||||
} else {
|
||||
erreurEmail.style.display = "none";
|
||||
emailEstValide = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Blocage formulaire si e-mail invalide
|
||||
form.addEventListener("submit", function (e) {
|
||||
if (!emailEstValide) {
|
||||
e.preventDefault();
|
||||
alert(EMAIL_TAKEN); // vient de PHP
|
||||
}
|
||||
});
|
||||
|
||||
// ---- Jauge mot de passe ----
|
||||
const passwordInput = document.getElementById("mot_de_passe");
|
||||
const segments = document.querySelectorAll(".strength-fill");
|
||||
const niveauText = document.getElementById("niveau-securite");
|
||||
|
||||
passwordInput.addEventListener("input", function () {
|
||||
const val = passwordInput.value;
|
||||
|
||||
segments.forEach(seg => seg.style.backgroundColor = '#ccc');
|
||||
niveauText.textContent = T.rule;
|
||||
niveauText.style.color = '#666';
|
||||
|
||||
const longOk = val.length >= 8;
|
||||
const lettre = /[A-Za-z]/.test(val);
|
||||
const chiffre = /\d/.test(val);
|
||||
const maj = /[A-Z]/.test(val);
|
||||
const special = /[^A-Za-z0-9]/.test(val);
|
||||
|
||||
let force = 0;
|
||||
if (longOk && lettre && chiffre) force++;
|
||||
if (maj) force++;
|
||||
if (special) force++;
|
||||
|
||||
if (force === 1) {
|
||||
segments[0].style.backgroundColor = 'red';
|
||||
niveauText.textContent = T.weak;
|
||||
niveauText.style.color = 'red';
|
||||
} else if (force === 2) {
|
||||
segments[0].style.backgroundColor = 'orange';
|
||||
segments[1].style.backgroundColor = 'orange';
|
||||
niveauText.textContent = T.medium;
|
||||
niveauText.style.color = 'orange';
|
||||
} else if (force >= 3) {
|
||||
segments.forEach(seg => seg.style.backgroundColor = 'green');
|
||||
niveauText.textContent = T.strong;
|
||||
niveauText.style.color = 'green';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user