begin process at 2012 05 29 06:04:03
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Javascript / DHTML / Ajax

 > 

CSS

 > 

Général

 > 

FBJS : ou mettre le javascript étant dans <head> en html sans le head en fbjs ?


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

FBJS : ou mettre le javascript étant dans <head> en html sans le head en fbjs ?

jeudi 3 février 2011 à 14:33:35 | FBJS : ou mettre le javascript étant dans <head> en html sans le head en fbjs ?

quinton75

Code Javascript :
<html> 
<head> 
<title>Webform</title> 
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 
<script language="javascript"> 
var dtCh='/'; 
var minYear=1900; 
var maxYear=2100; 
function isValidInteger(s){ 
var i; 
for(i=0;i<s.length;i++){ 
var c=s.charAt(i); 
if(((c<'0')||(c>'9'))) return false; 
} 
return true; 
} 
function stripCharsInBag(s,bag){ 
var i; 
var returnString=''; 
for(i=0;i<s.length;i++){ 
var c=s.charAt(i); 
if(bag.indexOf(c)==-1) returnString+=c; 
} 
return returnString; 
} 
function daysInFebruary(year){ 
return(((year%4==0)&&((!(year % 100 == 0))||(year%400==0)))?29:28); 
} 
function DaysArray(n){ 
for(var i=1;i<=n;i++){ 
this[i]=31; 
if(i==4||i==6||i==9||i==11){this[i]=30;} 
if(i==2){this[i]=29;} 
} 
return this; 
} 
function isDateOK(dtStr){ 
if(dtStr=='') return true; 
var daysInMonth=DaysArray(12); 
var pos1=dtStr.indexOf(dtCh); 
var pos2=dtStr.indexOf(dtCh,pos1+1); 
var strDay=dtStr.substring(0,pos1); 
var strMonth=dtStr.substring(pos1+1,pos2); 
var strYear=dtStr.substring(pos2+1); 
strYr=strYear; 
if(strDay.charAt(0)=='0'&&strDay.length>1) strDay=strDay.substring(1); 
if(strMonth.charAt(0)=='0'&&strMonth.length>1) strMonth=strMonth.substring(1); 
for(var i=1;i<=3;i++){ 
if(strYr.charAt(0)=='0'&&strYr.length>1) strYr=strYr.substring(1); 
} 
month=parseInt(strMonth); 
day=parseInt(strDay); 
year=parseInt(strYr); 
if(pos1==-1||pos2==-1){ 
alert('Le format de date devrait être : dd/mm/yyyy.'); 
return false; 
} 
if(strMonth.length<1||month<1||month>12){ 
alert('Veuillez entrer un mois valide.'); 
return false; 
} 
if(strDay.length<1||day<1||day>31||(month==2&&day>daysInFebruary(year))||day>daysInMonth[month]){ 
alert('Veuillez entrer un jour valide.'); 
return false; 
} 
if(strYear.length!=4||year==0||year<minYear||year>maxYear){ 
alert('Veuillez entrer une année &#65533; 4 chiffres comprise entre '+minYear+' et '+maxYear+'.'); 
return false; 
} 
if(dtStr.indexOf(dtCh,pos2+1)!=-1||isValidInteger(stripCharsInBag(dtStr,dtCh))==false){ 
alert('Veuillez entrer une date valide.'); 
return false; 
} 
return true; 
} 
function modifyDateFormat(dt){ 
var valuesTable=dt.value.split(dtCh); 
dt.value=valuesTable[1]+dtCh+valuesTable[0]+dtCh+valuesTable[2]; 
} 
function isEmail(emailAddress){ 
emailAddressValue=emailAddress.value.toLowerCase(); 
var countryTLDs=/^(ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|Fiddlesticks|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$/;
var gTLDs=/^(aero|biz|cat|com|coop|edu|gov|info|int|mil|museum|name|net|org|jobs)$/; 
var basicAddress=/^(.+)@(.+)$/; 
var specialChars='\\(\\)><@,;:\\\\\\\"\\.\\[\\]'; 



var validChars='\[^\\s'+specialChars+'\]'; 
var validCharset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\'-_.'; 
var quotedUser='(\"[^\"]*\")'; 



var atom=validChars+'+'; 
var word='('+atom+'|'+quotedUser+')'; 
var validUser=new RegExp('^'+word+'(\.'+word+')*$'); 
var symDomain=new RegExp('^'+atom+'(\.'+atom+')*$'); 
var matchArray=emailAddressValue.match(basicAddress); 
if(emailAddress.value==''||emailAddress==null){ 
return true; 
} 
if(matchArray==null){ 
alert('L\'adresse Email semble incorrecte,\nveuillez vérifier la syntaxe.'); 
emailAddress.focus(); 
return false; 
}else{ 
var user=matchArray[1]; 
var domain=matchArray[2]; 
for(i=0;i<user.length;i++){ 
if(validCharset.indexOf(user.charAt(i))==-1){ 
alert('L\'adresse Email contient des caractères invalides,\nveuillez vérifier la partie avant l\'arobase.'); 
emailAddress.focus(); 
return false; 
} 
} 
for(i=0;i<domain.length;i++){ 
if(validCharset.indexOf(domain.charAt(i))==-1){ 
alert('L\'adresse Email contient des caractères invalides,\nveuillez vérifier la partie après l\'arobase.'); 
emailAddress.focus(); 
return false; 
} 
} 
if(user.match(validUser)==null){ 
alert('L\'adresse Email semble incorrecte,\nveuillez vérifier la partie avant l\'arobase.'); 
emailAddress.focus(); 
return false; 
} 
var atomPat=new RegExp('^'+atom+'$'); 
var domArr=domain.split('.'); 
var len=domArr.length; 
for(i=0;i<len;i++){ 
if(domArr[i].search(atomPat)==-1){ 
alert('L\'adresse Email semble incorrecte,\nveuillez vérifier la partie après l\'arobase.'); 
emailAddress.focus(); 
return false; 
} 
} 
if((domArr[domArr.length-1].length==2)&&(domArr[domArr.length-1].search(countryTLDs)==-1)){ 
alert('L\'adresse Email semble incorrecte,\nveuillez vérifier le suffixe du domaine.'); 
emailAddress.focus(); 
return false; 
} 
if((domArr[domArr.length-1].length>2)&&(domArr[domArr.length-1].search(gTLDs)==-1)){ 
alert('L\'adresse Email semble incorrecte,\nveuillez vérifier le suffixe du domaine.'); 
emailAddress.focus(); 
return false; 
} 
if((domArr[domArr.length-1].length<2)||(domArr[domArr.length-1].length>6)){ 
alert('L\'adresse Email semble incorrecte,\nveuillez vérifier le suffixe du domaine.'); 
emailAddress.focus(); 
return false; 
} 
if(len<2){ 
alert('L\'adresse Email semble incorrecte.'); 
emailAddress.focus(); 
return false; 
} 
} 
return true; 
} 
String.prototype.trim = function() { return this.replace(/^\s*(\b.*\b|)\s*$/, "$1"); } 
function mandatoryText(input,fieldName){ 
if(input.value.trim()==''||input==null){ 
alert('Veuillez saisir '+fieldName+'.'); 
input.focus(); 
return false; 
} else { 
return true; 
} 
} 
function validForm(){ 
if(!mandatoryText(document.getElementById('EMAIL_FIELD'), 'Adresse e-mail')) return; 
if(!isEmail(document.getElementById('EMAIL_FIELD'))) return; 
if(!isDateOK(document.getElementById('DATEOFBIRTH_FIELD').value)) return; 
if(document.getElementById('DATEOFBIRTH_FIELD').value!='') modifyDateFormat(document.getElementById('DATEOFBIRTH_FIELD')); 
document.getElementById('emvForm').submit(); 
if(document.getElementById('DATEOFBIRTH_FIELD').value!='') modifyDateFormat(document.getElementById('DATEOFBIRTH_FIELD')); 
} 
</script> 
</head> 
<body> 
<form name="emvForm" id="emvForm" action="http://p2tre.emv3.com/D2UTF8" method="POST" target="_top"> 
<input type="hidden" name="emv_tag" value="xxxx" /> 
<input type="hidden" name="emv_ref" value="yyyy" /> 
<table> 
<tr> 
<td> 
Adresse e-mail 
</td> 
<td> 
<input type="text" id="EMAIL_FIELD" name="EMAIL_FIELD" value="" size="30" maxlength="64"> 
</td> 
</tr> 
<tr> 
<td> 
Prénom 
</td> 
<td> 
<input type="text" id="FIRSTNAME_FIELD" name="FIRSTNAME_FIELD" value="" size="30" maxlength="64"> 
</td> 
</tr> 
<tr> 
<td> 
Nom 
</td> 
<td> 
<input type="text" id="LASTNAME_FIELD" name="LASTNAME_FIELD" value="" size="30" maxlength="64"> 
</td> 
</tr> 
<tr> 
<td> 
Date de naissance 
</td> 
<td> 
<input type="text" id="DATEOFBIRTH_FIELD" name="DATEOFBIRTH_FIELD" value="" size="30" maxlength="64"> 
</td> 
</tr> 
<tr> 
<td> 
Genre 
</td> 
<td> 
<select id="TITLE_FIELD" name="TITLE_FIELD"> 
<option selected value=""></option> 
<option value="Homme">Homme</option> 
<option value="Femme">Femme</option> 
</select> 
</td> 
</tr> 
<tr> 
<td colspan="2" align="center"> 
<input type="button" value="Soumettre le formulaire" onClick="javascript:validForm();"> 
</td> 
</tr> 
</table> 
</form> 
</body> 
</html>
mardi 8 février 2011 à 22:51:08 | Re : FBJS : ou mettre le javascript étant dans <head> en html sans le head en fbjs ?

sapakus


Bonjour,

J'y connais rien en FBJS, mais je sais que rien ne t'empêche de mettre du JS dans le body, d'ailleurs le mieux dans ce cas est de le mettre à la fin du body (comme ça s'il y a des références dans le code JS aux éléments html de la page, il sait au moins de quoi on parle).
Donc mais le juste avant </body>, bref à la fin quoi!

Sapakus
mardi 8 février 2011 à 23:24:03 | Re : FBJS : ou mettre le javascript étant dans <head> en html sans le head en fbjs ?

quinton75

Oui j'avais deja essayé ça mais ça n'avait pas marcher...I

Il doit sans doute y avoir des choses à modifier mais tout ce que je vois en fbjs sur internet ne m'aide âs mais merci quand meme


Cette discussion est classée dans : var, alert, return, false, if


Répondre à ce message

Sujets en rapport avec ce message

Formulaire Newsletter facebook FBML/FBJS [ par quinton75 ] Bonjour,[^^clinoeil1][^^clinoeil1] Je souhaite intégrer un formulaire d'inscription à ma Newsletter sur ma page facebook Mon code source HTML d'inté Intégrer du javascirpit sur facebook (FBML/FBJS) [ par quinton75 ] Hello,[^^clinoeil1][^^clinoeil1][^^clinoeil1] Petite question à pose. Je souhaite intégrer un formulaire d'inscription à ma Newsletter sur ma page IE et Mozzila Firefox n'active pas mon javascript de mon formulaire [ par momosan77 ] Bonjour, J'ai un souci, c'est quand j'essaie de valider le formulaire dans Mozzila ou IE celui-ci ne prend pas compte du javascript Alors que si je l' Fonction non activer... [ par momosan77 ] Bonjour, j'expose mon soucis donc c'est que la fonction principale ne considère ni les fonction secondaire no les fonction principale. Alors que sa a Amélioration de script [ par charlieddr ] Bonjour, Je posséde un script (libre)pour un QCM mais le soucis,le concepteur ne soutient plus son script. Il est en deux parties, le test (liste.html Gestion de touches F5, BACKSPACE et ENTER (javascript et jQuery) [ par elara1970 ] Bonjour, Je souhaiterais gérer certaines touches du clavier en javascript (et jQuery). Le code fonctionne bien sous IE mais pas trop avec FF. Cepend changer le sens d'un texte qui défile [ par anthony428 ] Bonjour à tous, je viens de plonger les mains dans un site dont je suis chargé de faire la refonte et je souhaiterais changer le sens du texte qui d Chargement ajax du contenu au clic sur marqueur Google Maps V3 [ par vince240986 ] Bonjour, Voilà plusieurs jours que je bloque sur la création d'une fonction. L'idée est la suivante, j'ai crée une appli avec une base de données et Utilisation automatique du alert? [ par udoryl ] function saisirCalculerEtAfficher(){ var pond = prompt("Entrez la note maximale possible pour cette evaluation","100"); var test = validerPonderati Somme suite de caractere avec leur code ascii [ par greycats ] Bonsoir, Je souhaiterai calculer une suite de caractère avec leur code ascii par exemple: aa donnera a+a => 97+97=194 ou encore plus loin algo donn


Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,733 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales