1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
function check() {
var msg = "";
if (document.form_inscription.login.value == "") {
msg += "Veuillez saisir votre login\n";
document.form_inscription.login.style.backgroundColor = "aquamarine";
}
if (document.form_inscription.mdp.value == "") {
msg += "Veuillez saisir votre mot de passe\n";
document.form_inscription.mdp.style.backgroundColor = "aquamarine";
}
if (document.form_inscription.mdp.value.length < 8 ) {
msg += "Veuillez saisir un mot de passe plus long\n";
document.form_inscription.mdp.style.backgroundColor = "aquamarine";
}
if (document.form_inscription.confirm_mdp.value == "") {
msg += "Veuillez confirmer votre mot de passe\n";
document.form_inscription.confirm_mdp.style.backgroundColor = "aquamarine";
}
if (document.form_inscription.mdp.value != document.form_inscription.confirm_mdp.value) {
msg += "Veuillez saisir le même mot de passe en confirmation\n";
document.form_inscription.mdp.style.backgroundColor = "aquamarine";
document.form_inscription.conform_mdp.style.backgroundColor = "aquamarine";
}
//Vérification du mail s'il n'est pas vide on vérifie le . et @
if (document.form_inscription.mail.value != "") {
indexAroba = document.form_inscription.mail.value.indexOf('@');
indexPoint = document.form_inscription.mail.value.indexOf('.');
if ((indexAroba < 0) || (indexPoint < 0)) {//dans le cas ou il manque soit le . soit l'@ on modifie la couleur d'arrière plan du champ mail et définissons un message d'alerte
document.form_inscription.mail.style.backgroundColor = "aquamarine;";
msg += "Le mail est incorrect\n";
}
}
//Notre champs mail est vide donc on change la couleur et on défini un autre message d'alerte
if (document.form_inscription.mail.value == "") {
document.form_inscription.mail.style.backgroundColor = "aquamarine;";
msg += "Veuillez saisir votre mail.\n";
}
//Si aucun message d'alerte a été initialisé on retourne TRUE
if (msg == "") return(true);
//Si un message d'alerte a été initialisé on lance l'alerte
if (msg != "") {
alert(msg);
return(false);
}
} |
Partager