New to javascript but I have a good analytical mind....that being said, I have the following code in onSubmit() validation:

else if (cofaCOURRIEL == null || cofaCOURRIEL == "") {
		alert('Le champ COURRIEL doit être rempli.');
		document.forms["COFA_AIG"] ["COURRIEL"].focus();
		return false;
	}
	
	else if (cofaCOURRIEL) {
		if ( (atPOS < 1) || (dotPOS < atPOS + 2) || ((dotpos + 2) >= cofaCOURRIEL.length) ) {
			alert('Adresse de courriel invalide.');
			document.forms["COFA_AIG"] ["COURRIEL"].focus();
			return false;
		}
	}
	
	else if (cofaDATE == null || cofaDATE == "") {
		alert('Le champ DATE doit être rempli.');
		document.forms["COFA_AIG"] ["DATE"].focus();
		return false;
	}

I understand it is not the best way to validate client side, but I will be doing php server side validation as well.

My problem is that once the variable "cofaCOURRIEL" is valid, the script stops and returns true....not sure why...I'm guessing I'm missing an "else" statement after the embedded "if" statement, but I'm only guessing and if I'm correct, I wouldn't know what to put in the else statement to let it not break out of the validation...

any input?

Thanks!

if you use else if conditional statement, then your control goes for one valid condition.
If you want to go for every condition to be checked , then simply use if condition for every input.
and also check it:

if (cofaCOURRIEL == null || cofaCOURRIEL == "") {
		alert('Le champ COURRIEL doit être rempli.');
		document.forms["COFA_AIG"] ["COURRIEL"].focus();
		return false;
	}
	
	else {
		if ( (atPOS < 1) || (dotPOS < atPOS + 2) || ((dotpos + 2) >= cofaCOURRIEL.length) ) {
			alert('Adresse de courriel invalide.');
			document.forms["COFA_AIG"] ["COURRIEL"].focus();
			return false;
		}
	}
	
	 if (cofaDATE == null || cofaDATE == "") {
		alert('Le champ DATE doit être rempli.');
		document.forms["COFA_AIG"] ["DATE"].focus();
		return false;
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.