<!--
function twValide(nForm) {
  // ********************************************
  //  FONCTION UNIVERSELLE POUR FORCER LA SAISIE
  // DES TOUS LES TYPES DE CHAMPS D'UN FORMULAIRE
  // Plus plusieurs validations de champs.
  // ********************************************
  // twValide 2.2 (octobre 2001)
  // Création : Django (Oznog) Blais
  // http://www.trucsweb.com
  //
  // LIBRE DE DROITS à LA CONDITION DE LAISSER
  // CETTE REMARQUE.
  //
  // INSTRUCTION
  // Dans le fichier "valide.htm" ou sur le site 
  // http://www.trucsweb.com/Javascript/
  // (cliquer > Fonction de validation twValide)
  // ********************************************
  // MAJ - Octobre : Ajout des fonctions
  //                 - twValide_courriel()
  //                 - twValide_date()
  //     - Septembre : Ajustement de la fonction
  //                 - twValide_char()
  //                   Validation minimum de caractères
  //     - Septembre : Ajustement d'un bogue.
  //     - été 2001 : Version 2
  // ********************************************
  // COMPATIBILITé testée sur ces navigateurs
  // - Internet Explorer 5.0, 5.5, 6.0 (Win98/2000)
  // - Internet Explorer 3.0, 4.0 (Mac OS7.6+)
  // - Internet Explorer 4.5, 5.0, 6.0 (Mac G4)
  // - Mozilla 0.9.3 (Win98/2000)
  // - Netscape 4.7, 6.0 (Win98/2000)
  // - Communicator 4.0 (Mac OS6+)
  // - Navigator gold 3.0 (Mac OS6+)
  // - Netscape 4.5, 6.0 (Mac G4)
  // - Opera 5.0 (Win98/2000)
  //
  // COMPATIBILITé supposée
  // - Internet Explorer 4+ (Win)
  // - Netscape 3+ (Win)
  // - Opera 4+ (Win)
  // - AOL 4+ (Win)
  // ********************************************
  
  // ********************************************
  // Ne rien modifier ci-dessous
  // ********************************************
  var RdCkOk = false;
  var RdMess = "";
  var CbMess = "";
  var CbCkOk = false;
  var msg = ""
  
  var ar = "_____________________________________________________________\n\n";
      ar += "!  \u0627\u0644\u0645\u0631\u062c\u0648  \u062a\u0639\u0628\u0626\u0629 \u0643\u06B5 \u0627\u0644\u062d\u0642\u0648\u0644 \u0627\u0644\u0625\u0644\u0632\u0627\u0645\u064a\u0629  \n"; //المرجو تعبئة كلّ الحقول الإِلزامية
      ar += "_____________________________________________________________\n\n";
        
      
  for (var i=0; i<nForm.elements.length; i++) {
    if (varValid.indexOf(nForm.elements[i].name) == -1 && nForm.elements[i].type != 'submit' && nForm.elements[i].type != 'reset' && nForm.elements[i].type != 'button' && nForm.elements[i].type != 'hidden') {
      if (nForm.elements[i].type == 'select-one') {
        if (nForm.elements[i].selectedIndex == 0) {
          msg += "\n         " + nForm.elements[i].name;
        }
      } else
      if (nForm.elements[i].type == 'select-multiple') {
        if (nForm.elements[i].selectedIndex < 0) {
          msg += "\n         " + nForm.elements[i].name;
        }
      } else
      if (nForm.elements[i].type == 'text') {
        if (nForm.elements[i].value == '') {
          msg += "\n         " + nForm.elements[i].name;
        }
      } else
      if (nForm.elements[i].type == 'textarea') {
        if (nForm.elements[i].value == '') {
          msg += "\n         " + nForm.elements[i].name;
        }
      } else
      if (nForm.elements[i].type == 'password') {
        if (nForm.elements[i].value == '') {
          msg += "\n         " + nForm.elements[i].name;
        }
      } else
      if (nForm.elements[i].type == 'radio') {
        if (nForm.elements[i].checked) {
            RdCkOk = true;
            RdMess = "";
        }
        if (RdCkOk == false) {
          RdMess = "\n         " + nForm.elements[i].name;
        }
      } else
      if (nForm.elements[i].type == 'checkbox'&&CbCkOk == false) {
        if (nForm.elements[i].checked) {
          CbCkOk = true;
          CbMess = "";
        }
        if (CbCkOk == false) {
            CbMess = "\n         " + nForm.elements[i].name;
        }
      } 	
    }
  }
  if (msg.length != 0||RdMess.length != 0||CbMess.length != 0) {
    msg += RdMess + CbMess; 
    msg = ar +  "\n"; 
    alert(msg);
    return false;
  }
}
// ********************************************
// FIN DE LA FONCTION twValide()
// ********************************************


// ********************************************
// FONCTION twValide_char()
// ********************************************
function twValide_char(nChamp,nAccepte,nbr) {
  // Ajouter ce code dans la saisie du champs
  //  onBlur="twValide_char(this,'()-0123456789')"
  // Les caractères acceptés peuvent etre changes
  var ok = "oui";
  var min = "oui";
  var nChar;
  for (var i=0; i<nChamp.value.length; i++) {
    nChar = "" + nChamp.value.substring(i, i+1);
    if (nAccepte.indexOf(nChar) == "-1") ok = "non";
  }
  if (ok == "non") {
     
      alert ("\n ! \u0644\u0627 \u064a\u0645\u0643\u0646 \u0623\u0646 \u064a\u0634\u0645\u0644 \u0631\u0642\u0645 \u0627\u0644\u0647\u0627\u062a\u0641 \u063a\u064a\u0631 \u0627\u0644\u0623\u0631\u0642\u0627\u0645    \n ") ;   //لا يمكن أن يشمل رقم الهاتف غير الأرقام
   
    nChamp.focus();
    nChamp.select();
  }
  if (nChamp.value.length < nbr&&nChamp.value.length > 0) min = "non";
  if (min == "non") {
    if (nlang=="ar")
      alert("\nSaisie invalide!\nAssurez-vous d'entrer au moins " + nbr + " caractères.");
        
    nChamp.focus();
    nChamp.select();
  }
}


// ********************************************
// FONCTION twValide_char()
// ********************************************
function twValide_char1(nChamp,nAccepte,nbr) {
  // Ajouter ce code dans la saisie du champs
  //  onBlur="twValide_char(this,'()-0123456789')"
  // Les caractères acceptés peuvent etre changés
  var ok = "oui";
  var min = "oui";
  var nChar;
  for (var i=0; i<nChamp.value.length; i++) {
    nChar = "" + nChamp.value.substring(i, i+1);
    if (nAccepte.indexOf(nChar) == "-1") ok = "non";
  }
  if (ok == "non") {
    
      alert("\n ! \u0644\u0627 \u064a\u0645\u0643\u0646 \u0623\u0646 \u064a\u0634\u0645\u0644 \u0631\u0642\u0645 \u0628\u0637\u0627\u0642\u0629 \u0633\u0641\u0631 \u0641\u0644\u0627\u064a\u0631  \u063a\u064a\u0631 \u0627\u0644\u0623\u0631\u0642\u0627\u0645    \n "); //لا يمكن أن يشمل رقم بطاقة سفر فلايرغير الأرقام
    nChamp.focus();
    nChamp.select();
  }
  if (nChamp.value.length < nbr&&nChamp.value.length > 0) min = "non";
  if (min == "non") {
    if (nlang=="ar")
      alert("\nSaisie invalide!\nAssurez-vous d'entrer au moins " + nbr + " caractères.");
    
    nChamp.focus();
    nChamp.select();
  }
}

// ********************************************
// FONCTION twValide_courriel()
// ********************************************
function twValide_courriel(nChamp) {
  // Ajouter ce code dans la saisie du champs
  //  onBlur="twValide_courriel(this)"
  if (nChamp.value.length > 0) {
    if ((nChamp.value.lastIndexOf(".") < nChamp.value.indexOf("@")+3 
      || nChamp.value.lastIndexOf(".") > nChamp.value.length-3 
      || nChamp.value.indexOf("@") < 1 ) 
      || nChamp.value.indexOf("@") != nChamp.value.lastIndexOf("@")) {
      
        alert("\n ! \u0627\u0644\u0628\u0631\u064a\u062f \u0627\u0644\u0625\u0644\u0643\u062a\u0631\u0648\u0646\u064a \u062e\u0627\u0637\u0626     "); //! البريد الإلكتروني خاطئ
      nChamp.focus();
      nChamp.select();
    }
  }
}

// ********************************************
// FONCTION twValide_date()
// ********************************************
function twValide_date(nDate,nA1,nA2,nFormat) {
  // Ajouter ce code dans la saisie du champs date
  //  onBlur="twValide_date(this,1950,2020,'jj/mm/aaaa')"
  // La date valide doit etre entre 1950 et 2020.
  //    vous pouvez changer l'interval.
  // Format valide: (ne pas utiliser d'autre format...
  // - jj/mm/aaaa
  // - mm/jj/aaaa
  // - aaaa/mm/jj
  // Noter que vous devriez indiquer à l'usager le format valide...
  var ok = "oui";
  var nChar;
  var aDate;
  var nJ;
  var nM;
  var nA;
  var jMax = 31;
  nAccepte = "0123456789/";
  if (nDate.value.length > 0) {
    if (nDate.value.length < 8 || nDate.value.length > 10) ok = "non";
    for (var i=0; i<nDate.value.length; i++) {
      nChar = "" + nDate.value.substring(i, i+1);
      if (nAccepte.indexOf(nChar) == "-1") ok = "non";
    }
    if (ok == "oui") {
      aDate = nDate.value.split("/");
      if (nFormat == "jj/mm/aaaa") { nJ = aDate[0]; nM = aDate[1]; nA = aDate[2];
      } else if (nFormat == "mm/jj/aaaa") { nJ = aDate[1]; nM = aDate[0]; nA = aDate[2];
        } else if (nFormat == "aaaa/mm/jj") { nJ = aDate[2]; nM = aDate[1]; nA = aDate[0]; }
      if ((nJ < 1 || nJ > jMax) || (nM < 1 || nM > 12) || (nA < nA1 || nA > nA2)) ok = "non";
      else {
        if (nM == 2) { 
          if (AnneeBissex(nA) == true) { jMax = 29 } else { jMax = 28 }
        }
        if ((nM == 1 || nM == 3 || nM == 5 || nM == 7 || nM == 8 || nM == 10 || nM == 12)) jMax = 31
        if ((nM == 4 || nM == 6 || nM == 9 || nM == 11)) jMax = 30
        if (nJ < 1 || nJ > jMax) ok = "non";
      }
    }
    if (ok == "non") {
      nDate.focus();
      nDate.select();
      
        alert ("\n  \u0627\u0644\u0627\u0631\u064a\u062e  \u062e\u0627\u0637\u0626 ! \u0627\u0644\u0645\u0631\u062c\u0648  \u0627\u0644\u062a\u0635\062d\u064a\u062d    : "+nFormat+"\nentre "+nA1+" et "+nA2);  //التاريخ خاطئ! المرجو التصحيح
      
    }
  }
}

// ********************************************
// FONCTION twCompteur_Texte()
// ********************************************
function twCompteur_Texte(nTexte, nCompteur, nLimite) {
  // Ajouter ce code dans la saisie du champ "textarea"
  // onKeyDown="twCompteur_Texte(this,this.form.compte,2000);"
  // onKeyUp="twCompteur_Texte(this,this.form.compte,2000);"
  // 2000 represente le nombre maximum de caracteres accepté
  // Vous devez aussi ajouter une boite de saisie qui
  // indique le nombre de caractères restant.
  // <input readonly="readonly" type="text" name="compte" value="2000">
  if (nTexte.value.length > nLimite)
    nTexte.value = nTexte.value.substring(0, nLimite);
  else 
    nCompteur.value = nLimite - nTexte.value.length;
}
// -->
