25 lines
948 B
JavaScript
25 lines
948 B
JavaScript
let messageAffiche = false;
|
|
window.onload = init;
|
|
|
|
function init(){
|
|
let password = document.getElementById("password");
|
|
let confirmation = document.getElementById("confirmation");
|
|
|
|
password.oninput = verifPassword;
|
|
confirmation.oninput = verifPassword;
|
|
}
|
|
|
|
function verifPassword() {
|
|
let message = "Les mots de passe ne correspondent pas.";
|
|
if( !messageAffiche && password.value != "" && confirmation.value!="" && password.value != confirmation.value ){
|
|
confirmation.insertAdjacentHTML("afterend", "<p id='error' class='error'>" + message + "</p>");
|
|
document.getElementById("submit").disabled = true;
|
|
messageAffiche = true;
|
|
}
|
|
else if ( messageAffiche && password.value == confirmation.value ) {
|
|
let child = document.getElementById("error");
|
|
child.parentNode.removeChild(child);
|
|
document.getElementById("submit").disabled = false;
|
|
messageAffiche = false;
|
|
}
|
|
} |