Hi
Im bulding a form and during the validation i found out that two line of code are causing problem.
If i remove them everything is fine.Unfortunately i need them to hide the spans with the .invalide class.
I want the spans to be visible only if there is an error.
Here is my webpage : http://kmultim.com/index.php?idSection=contact
‘Clicking on Envoyer start the fonction’
If i remove thes two line the alert will pop-up
.
erreurSpan[i].innerHTML ='';
erreurSpan[i].style.display ='none';
function validForm(oForm)
{
var erreur = 0;
var erreurSpan = document.getElementsByClassName('invalide')// liste des span avec la classe error
//var regExpCourriel = /^([\\w-]+(?:\\.[\\w-]+)*)@((?:[\\w-]+\\.)*\\w[\\w-]{0,66})\\.([a-z]{2,6}(?:\\.[a-z]{2})?)$/i ;
for(var i = 0; i < oForm.elements.length ; i++)
{
erreurSpan[i].innerHTML ='';// buggy line 1
erreurSpan[i].style.display ='none'; // buggy line 2
var laValeurInp = oForm.elements[i].value
if(oForm.elements[i].className == "inputForm") // get the element of the form with the class inputForm
{
if(laValeurInp == "") // input or text is empte
{
erreurSpan[i].innerHTML ="Ce champ ne doit pas être vide";
erreurSpan[i].style.display ="block";
erreur = 1;
}else
{
if(laValeurInp.length < 2) //input or text is less than 2 characters
{
erreurSpan[i].innerHTML ="Ce doit contenir au moin deux charactères";
erreurSpan[i].style.display ="block";
erreur = 1;
}
}
}
}
alert(1);
}