/*
* vérification et aide à la saisie des champs
*/
function surligne( champ, erreur )
{
if(erreur)
//champ.style.backgroundColor = "#fba";
champ.style.border = "3px solid #a00";
else
//champ.style.backgroundColor = "";
champ.style.border = "3px solid #0a0";
}
function verifChamp( champ, regex, champComment, exemple )
{
if ( champ.value.length < 1 )
{
surligne(champ, true);
champComment.textContent = "Veuillez remplir ce champ";
champComment.style.color = "#a00";
return false;
}
else if(!regex.test(champ.value))
{
surligne(champ, true);
champComment.textContent = "Saisie incorrecte, exemple : " + exemple;
champComment.style.color = "#a00";
return false;
}
else
{
surligne(champ, false);
champComment.textContent = "";
return true;
}
}
function verifChampOpt( champ, regex, champComment, exemple, opt = false )
{
if ( ( champ.value.length == 0 ) && opt )
{
surligne(champ, false);
champComment.textContent = "";
return true;
}
if ( champ.value.length < 1 )
{
surligne(champ, true);
champComment.textContent = "Veuillez remplir ce champ";
champComment.style.color = "#a00";
return false;
}
else if(!regex.test(champ.value))
{
surligne(champ, true);
champComment.textContent = "Saisie incorrecte, exemple : " + exemple;
champComment.style.color = "#a00";
return false;
}
else
{
surligne(champ, false);
champComment.textContent = "";
return true;
}
}
function verifConfirmPwd( champ, champConfirm, champComment )
{
if ( champConfirm.value != champ.value )
{
surligne(champ, true);
champComment.textContent = "La confirmation ne correspond pas au mot de passe";
champComment.style.color = "#a00";
return false;
}
else
{
surligne(champ, false);
champComment.textContent = "";
return true;
}
}
function Afficher( pwd_id, img )
{
if (pwd_id.type === "password")
{
pwd_id.type = "text";
img.setAttribute("src", "img/hide.png");
}
else
{
pwd_id.type = "password";
img.setAttribute("src", "img/eye.png");
}
}