PROJET-WEB_STRI1A/WEB/inscription.js
2019-04-18 18:37:23 +02:00

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;
}
}