function limite(zone,max,affichage){
if(zone.value.length>=max){zone.value=zone.value.substring(0,max);}
var nb=max-zone.value.length
affichage.value=nb}
function verifTextarea(tarea,info,tailleMax){
var texte=tarea.value
var taille=tarea.value.length
if(taille>tailleMax){
var texte_ok=texte.substring(0,tailleMax)
tarea.value=texte_ok
}else{
info.value=(tailleMax-taille)}}
function verifPseudo(donnee){
chaine=new String(donnee)
longueur=chaine.length
for(var i=0;i<longueur;i++){
code=chaine.charCodeAt(i)
if((code==45)||((code>=48)&&(code<=57))||((code>=65)&&(code<=90))||((code>=97)&&(code<=122))){}
else{
return("Le caract&#232;re '"+chaine.charAt(i)+"' est interdit")}}
return ""}
function verifSMS(donnee){
chaine=new String(donnee)
longueur=chaine.length
for(var i=0;i<longueur;i++){
code=chaine.charCodeAt(i)
if(((code>=32)&&(code<=126))||(code==192)||(code==194)||(code==199)||(code==206)||(code==207)||(code==212)||(code==214)||(code==217)||(code==219)||(code==220)||(code==224)||(code==226)||(code==238)||(code==239)||(code==244)||(code==246)||(code==249)||(code==251)||(code==252)||((code>=65)&&(code<=90))||((code>=97)&&(code<=122))||((code>=200)&&(code<=203))||((code>=231)&&(code<=235))){}
else{
return("Le caract&#232;re '"+chaine.charAt(i)+"' est interdit")}}
return ""}
function verifTexte(donnee){
chaine=new String(donnee)
longueur=chaine.length
for(var i=0;i<longueur;i++){
code=chaine.charCodeAt(i)
if((code==32)||(code==39)||(code==44)||(code==45)||(code==46)||(code==180)||(code==192)||(code==194)||(code==199)||(code==206)||(code==207)||(code==212)||(code==214)||(code==217)||(code==219)||(code==220)||(code==224)||(code==226)||(code==238)||(code==239)||(code==244)||(code==246)||(code==249)||(code==251)||(code==252)||((code>=65)&&(code<=90))||((code>=97)&&(code<=122))||((code>=200)&&(code<=203))||((code>=231)&&(code<=235))){}
else{
return("Le caract&#232;re '"+chaine.charAt(i)+"' est interdit")}}
return ""}
function verifAlphaNum(donnee){
chaine=new String(donnee)
longueur=chaine.length
for(var i=0;i<longueur;i++){
code=chaine.charCodeAt(i)
if((code==32)||(code==39)||(code==44)||(code==45)||(code==46)||(code==180)||(code==192)||(code==194)||(code==199)||(code==206)||(code==207)||(code==212)||(code==214)||(code==217)||(code==219)||(code==220)||(code==224)||(code==226)||(code==238)||(code==239)||(code==244)||(code==246)||(code==249)||(code==251)||(code==252)||((code>=48)&&(code<=57))||((code>=65)&&(code<=90))||((code>=97)&&(code<=122))||((code>=200)&&(code<=203))||((code>=231)&&(code<=235))){}
else{
return("Le caract&#232;re '"+chaine.charAt(i)+"' est interdit")}}
return ""}
function verifAlphaNumSouple(donnee){
chaine=new String(donnee)
longueur=chaine.length
for(var i=0;i<longueur;i++){
code=chaine.charCodeAt(i)
if((code==10)||(code==13)||(code==32)||(code==33)||(code==63)||(code==180)||(code==192)||(code==194)||(code==199)||(code==206)||(code==207)||(code==212)||(code==214)||(code==217)||(code==219)||(code==220)||(code==224)||(code==226)||(code==238)||(code==239)||(code==244)||(code==246)||(code==249)||(code==251)||(code==252)||((code>=65)&&(code<=90))||((code>=39)&&(code<=46))||((code>=48)&&(code<=58))||((code>=65)&&(code<=90))||((code>=97)&&(code<=122))||((code>=200)&&(code<=203))||((code>=231)&&(code<=235))){}
else{
return("Le caract&#232;re '"+chaine.charAt(i)+"' est interdit")}}
return ""}
function verifEntier(donnee){
chaine=new String(donnee)
longueur=chaine.length
for(var i=0;i<longueur;i++){
code=chaine.charCodeAt(i)
if(((code>=48)&&(code<=57))){}
else{
return("Le caract&#232;re '"+chaine.charAt(i)+"' est interdit")}}
return ""}
function verifReel(donnee){
chaine=new String(donnee)
longueur=chaine.length
partieEntiere=true
for(var i=0;i<longueur;i++){
code=chaine.charCodeAt(i)
if(((code>=48)&&(code<=57))||((code==44)&&partieEntiere)||((code==46)&&partieEntiere)){
if((code==44)||(code==46)){
partieEntiere=false}}
else{
return("Le caract&#232;re '"+chaine.charAt(i)+"' est interdit")}}
return ""}
function verifURL(donnee){
chaine=new String(donnee)
expreg=new RegExp("^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$")
if(!expreg.test(chaine)){
return("Le format d\'url n\'est pas conforme")}
return ""}
function verifEmail(donnee){
chaine=new String(donnee)
expreg=new RegExp("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\\.[a-zA-Z0-9]{2,4}$")
if(!expreg.test(chaine)){
return("Le format d\'email n\'est pas conforme")}
return ""}
function verifDate(donnee){
if(donnee.length<10){return("Format non valide")}
var iDay=donnee.substring(0,2)
var iMonth=donnee.substring(3,5)
var iYear=donnee.substring(6)
iDay=iDay*1
iMonth=iMonth*1
iYear=iYear*1
var rDate=new Date(iYear,iMonth,iDay)
if(rDate.toString()=="NaN"){return("Format non valide")}
if(iYear%4==0&&iYear%100 !=0 || iYear%400==0){
fev=29
}else{
fev=28}
nbJours=new Array(31,fev,31,30,31,30,31,31,30,31,30,31)
if((iMonth<1)||(iMonth>12)||(iDay<1)||(iDay>nbJours[iMonth-1])){
return("Format non valide")}
return ""}
function verifDateN(donnee){
var majorite=new Number(18)
if(donnee.length<10){return("Format non valide")}
var iDay=donnee.substring(0,2)
var iMonth=donnee.substring(3,5)
var iYear=donnee.substring(6)
iDay=iDay*1
iMonth=iMonth*1
iYear=iYear*1
var rDate=new Date(iYear,iMonth,iDay)
if(rDate.toString()=="NaN"){return("Format non valide")}
if(iYear%4==0&&iYear%100 !=0 || iYear%400==0){
fev=29
}else{
fev=28}
nbJours=new Array(31,fev,31,30,31,30,31,31,30,31,30,31)
if((iMonth<1)||(iMonth>12)||(iDay<1)||(iDay>nbJours[iMonth-1])){
return("Format non valide")}
var dateCourante=new Date()
var anneeCourante=dateCourante.getFullYear()*1
var moisCourant=(dateCourante.getMonth()*1)+1
var joursCourant=dateCourante.getDate()*1
if(((anneeCourante-iYear)<majorite)||(((anneeCourante-iYear)==majorite)&&(moisCourant<iMonth))||(((anneeCourante-iYear)==majorite)&&(moisCourant=iMonth)&&(joursCourant<iDay))){
return("Format non valide (rappel: vous devez &#234;tre majeur)")}
return ""}
function verifFormat(nomChamp,champ,nbMin,nbMax,typeDonnee,champAffichage){
var regExpBeginning=/^\s+/
var regExpEnd=/\s+$/
ch=new String(champ.value)
ch=ch.replace(regExpBeginning,"").replace(regExpEnd,"")
lng=ch.length
if((champ.value==null)&&(nbMin==0)){
return true}
if((champ.value=="")&&(nbMin==0)){
return true}
switch(typeDonnee){
case "pseudo":
ret=verifPseudo(ch)
break
case "texte":
ret=verifTexte(ch)
break
case "alphaNum":
ret=verifAlphaNum(ch)
break
case "alphaNumSouple":
ret=verifAlphaNumSouple(ch)
break
case "entier":
ret=verifEntier(ch)
break
case "reel":
ret=verifReel(ch)
break
case "email":
ret=verifEmail(ch)
break
case "sms":
ret=verifSMS(ch)
break
case "url":
ret=verifURL(ch)
break
case "date":
ret=verifDate(ch)
break
case "dateN":
ret=verifDateN(ch)
break
case "libre":
ret=""
break}
if(ret !=""){
champAffichage.innerHTML=ret+" dans le champ "+nomChamp
try{
champ.focus()
}catch(e){}
return false}
if(lng<nbMin){
champAffichage.innerHTML=nomChamp+" doit avoir une longueur de "+nbMin+" caract&#232;res minimum."
try{
champ.focus()
}catch(e){}
return false}
if(lng>nbMax){
champAffichage.innerHTML=nomChamp+" doit avoir une longueur de "+nbMax+" caract&#232;res maximum."
try{
champ.focus()
}catch(e){}
return false}
champAffichage.innerHTML=" "
return true}


