You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PROJET-WEB_STRI1A/WEB/inscription.js

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