﻿
function ChampNonVide(ChampNom,message,Form) {
 if (Form.elements[ChampNom].value.length < 1) {
  alert(" "+message);
  Form.elements[ChampNom].focus();
  return true;
 }
}

function EmailValid (ChampNom,Form) {
 adresse = Form.elements[ChampNom].value;
 var place = adresse.indexOf("@",1);
 var point = adresse.indexOf(".",place+1);
  if ((place > -1)&&(adresse.length >2)&&(point > 1)) {
  return false;
  }
	else {
   alert("Votre adresse e-mail n'est pas valide");
   Form.elements[ChampNom].focus();
   return true;
  }
}


function validForm(Form) {

 if (ChampNonVide('nom' ,'Veuillez saisir votre nom', Form)) return false; 
 if (ChampNonVide('prenom' ,'Veuillez saisir votre prénom', Form)) return false;
 if (ChampNonVide('fonction' ,'Veuillez saisir votre fonction', Form)) return false;
 if (ChampNonVide('dept' ,'Veuillez sélectionner un département', Form)) return false;
 if (ChampNonVide('societe' ,'Veuillez saisir votre société', Form)) return false;
 if (EmailValid ('email' , Form)) return false;
 if (ChampNonVide('cp' ,'Veuillez saisir votre code postal', Form)) return false;
 if (ChampNonVide('tel' ,'Veuillez saisir votre numéro de téléphone', Form)) return false;
}

function validSimpleForm(Form) {
 if (ChampNonVide('nom' ,'Veuillez saisir votre nom', Form)) return false; 
 if (ChampNonVide('prenom' ,'Veuillez saisir votre prénom', Form)) return false;
 if (ChampNonVide('societe' ,'Veuillez saisir votre société', Form)) return false;
 if (EmailValid ('email' , Form)) return false;
 if (ChampNonVide('tel' ,'Veuillez saisir votre numéro de téléphone', Form)) return false;
}


