Bonjour à vous tous
Voila je reviens vers vous pour me donner votre avis sur la "propreté" de ce code. J'ai modifié quelque chose d'existant. Sorano je n'ais pas vraiment saisi l'histoire des .<br>. Cela nescessite une feuille de style ?
Merci à vous
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Le SEL</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><link href="style.css" rel="stylesheet" type="text/css">
<!-- calendar stuff -->
<link rel="stylesheet" type="text/css" href="calendar/calendar-blue2.css" />
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<!-- END calendar stuff -->
<!-- expand/collapse function -->
<SCRIPT type=text/javascript>
<!--
function collapseElem(obj)
{
var el = document.getElementById(obj);
el.style.display = 'none';
}
function expandElem(obj)
{
var el = document.getElementById(obj);
el.style.display = '';
}
//-->
</SCRIPT>
<!-- expand/collapse function -->
<!-- expand/collapse function -->
<SCRIPT type=text/javascript>
<!--
// collapse all elements, except the first one
function collapseAll()
{
var numFormPages = 1;
for(i=2; i <= numFormPages; i++)
{
currPageId = ('mainForm_' + i);
collapseElem(currPageId);
}
}
//-->
</SCRIPT>
<!-- expand/collapse function -->
<!-- validate -->
<SCRIPT type=text/javascript>
<!--
function validateField(fieldId, fieldBoxId, fieldType, required)
{
fieldBox = document.getElementById(fieldBoxId);
fieldObj = document.getElementById(fieldId);
if(fieldType == 'text' || fieldType == 'textarea' || fieldType == 'password' || fieldType == 'file' || fieldType == 'phone' || fieldType == 'website')
{
if(required == 1 && fieldObj.value == '')
{
fieldObj.setAttribute("class","mainFormError");
fieldObj.setAttribute("className","mainFormError");
fieldObj.focus();
return false;
}
}
else if(fieldType == 'menu' || fieldType == 'country' || fieldType == 'state')
{
if(required == 1 && fieldObj.selectedIndex == 0)
{
fieldObj.setAttribute("class","mainFormError");
fieldObj.setAttribute("className","mainFormError");
fieldObj.focus();
return false;
}
}
else if(fieldType == 'email')
{
if((required == 1 && fieldObj.value=='') || (fieldObj.value!='' && !validate_email(fieldObj.value)))
{
fieldObj.setAttribute("class","mainFormError");
fieldObj.setAttribute("className","mainFormError");
fieldObj.focus();
return false;
}
}
}
function validate_email(emailStr)
{
apos=emailStr.indexOf("@");
dotpos=emailStr.lastIndexOf(".");
if (apos<1||dotpos-apos<2)
{
return false;
}
else
{
return true;
}
}
function validateDate(fieldId, fieldBoxId, fieldType, required, minDateStr, maxDateStr)
{
retValue = true;
fieldBox = document.getElementById(fieldBoxId);
fieldObj = document.getElementById(fieldId);
dateStr = fieldObj.value;
if(required == 0 && dateStr == '')
{
return true;
}
if(dateStr.charAt(2) != '/' || dateStr.charAt(5) != '/' || dateStr.length != 10)
{
retValue = false;
}
else // format's okay; check max, min
{
currDays = parseInt(dateStr.substr(0,2),10) + parseInt(dateStr.substr(3,2),10)*30 + parseInt(dateStr.substr(6,4),10)*365;
//alert(currDays);
if(maxDateStr != '')
{
maxDays = parseInt(maxDateStr.substr(0,2),10) + parseInt(maxDateStr.substr(3,2),10)*30 + parseInt(maxDateStr.substr(6,4),10)*365;
//alert(maxDays);
if(currDays > maxDays)
retValue = false;
}
if(minDateStr != '')
{
minDays = parseInt(minDateStr.substr(0,2),10) + parseInt(minDateStr.substr(3,2),10)*30 + parseInt(minDateStr.substr(6,4),10)*365;
//alert(minDays);
if(currDays < minDays)
retValue = false;
}
}
if(retValue == false)
{
fieldObj.setAttribute("class","mainFormError");
fieldObj.setAttribute("className","mainFormError");
fieldObj.focus();
return false;
}
}
//-->
</SCRIPT>
<!-- end validate -->
<style>
ul { list-style-type:none; list-style-position:outside; margin:0; padding:0; }
ul li { margin:5px 0 5px 0; }
label {
display: block;
float:left;
width:100px;
text-transform:capitalize;
}
</style>
</head>
<body onLoad="collapseAll()">
<div id="mainForm">
<div id="formHeader">
<h2 class="formInfo">sel</h2>
<p class="formInfo"></p>
</div>
<BR/><!-- begin form -->
<form method=post enctype=multipart/form-data action=processor.php onSubmit="return validatePage1();"><ul class=mainForm id="mainForm_1">
<fieldset>
<legend>information premiere personne</legend>
<li class="mainForm" id="fieldBox_1"><label class="formFieldQuestion">nom *</label><input class=mainForm type=text name=field_1 id=field_1 size='20' value=''></li>
<li class="mainForm" id="fieldBox_2"><label class="formFieldQuestion">prenom *</label><input class=mainForm type=text name=field_2 id=field_2 size='20' value=''></li>
<li class="mainForm" id="fieldBox_3"><label class="formFieldQuestion">ville *</label><input class=mainForm type=text name=field_3 id=field_3 size='20' value=''></li>
<li class="mainForm" id="fieldBox_4"><label class="formFieldQuestion">mail *</label><input class=mainForm type=email name=field_4 id=field_4 size=20 value="" style="background-image:url(imgs/email.png); background-repeat: no-repeat; padding: 2px 2px 2px 25px;"></li>
</fieldset>
</br>
<fieldset>
<legend>information deuxième personne</legend>
<li class="mainForm" id="fieldBox_5"><label class="formFieldQuestion">nom *</label><input class=mainForm type=text name=field_5 id=field_5 size='20' value=''></li>
<li class="mainForm" id="fieldBox_6"><label class="formFieldQuestion">prenom *</label><input class=mainForm type=text name=field_6 id=field_6 size='20' value=''></li>
<li class="mainForm" id="fieldBox_7"><label class="formFieldQuestion">ville *</label><input class=mainForm type=text name=field_7 id=field_7 size='20' value=''></li>
<li class="mainForm" id="fieldBox_8"><label class="formFieldQuestion">mail *</label><input class=mainForm type=email name=field_8 id=field_8 size=20 value="" style="background-image:url(imgs/email.png); background-repeat: no-repeat; padding: 2px 2px 2px 25px;"></li>
</fieldset>
</br>
<fieldset>
<legend>nature de l'échange</legend>
<li class="mainForm" id="fieldBox_9"><label class="formFieldQuestion">intitule *</label><input class=mainForm type=text name=field_9 id=field_9 size='20' value=''></li>
<li class="mainForm" id="fieldBox_10"><label class="formFieldQuestion">categorie *</label><select class=mainForm name=field_10 id=field_10><option value=''></option><option value="bricolage">bricolage</option><option value="reparation">reparation</option><option value="jardinage">jardinage</option><option value="formation">formation</option><option value="administratif">administratif</option><option value="cours">cours</option><option value="autres">autres</option></select></li>
<li class="mainForm" id="fieldBox_11"><label class="formFieldQuestion">date *</label><input type=text name=field_11 id=field_11 value=""><button type=reset class=calendarStyle id=fieldDateTrigger_11></button><SCRIPT type='text/javascript'> Calendar.setup({
inputField : "field_11",
ifFormat : "%m/%d/%Y",
showsTime : false,
button : "fieldDateTrigger_11",
singleClick : true,
step : 1
});</SCRIPT></li>
<li class="mainForm" id="fieldBox_12"><label class="formFieldQuestion">lieu *</label><input class=mainForm type=text name=field_12 id=field_12 size='20' value=''></li>
</fieldset>
</br>
<fieldset>
<legend>Montant de l'échange</legend>
<li class="mainForm" id="fieldBox_13"><label class="formFieldQuestion">montant *</label><input class=mainForm type=text name=field_13 id=field_13 size='20' value=''></li>
</fieldset>
</br>
<fieldset>
<legend>Description de l'échange</legend>
<li class="mainForm" id="fieldBox_14"><label class="formFieldQuestion">ponctuel </label><span><input class=mainForm type=checkbox name=field_14[] id=field_14_option_1 value="oui" /></span></li>
<li class="mainForm" id="fieldBox_15"><label class="formFieldQuestion">regulier </label><span><input class=mainForm type=checkbox name=field_15[] id=field_15_option_1 value="oui" /></span></li>
<li class="mainForm" id="fieldBox_16"><label class="formFieldQuestion">individuel </label><span><input class=mainForm type=checkbox name=field_16[] id=field_16_option_1 value="oui" /></span></li>
<li class="mainForm" id="fieldBox_17"><label class="formFieldQuestion">collectif </label><span><input class=mainForm type=checkbox name=field_17[] id=field_17_option_1 value="oui" /></span></li>
</fieldset>
</br>
<fieldset>
<legend>Commentaires</legend>
<li class="mainForm" id="fieldBox_18"><label class="formFieldQuestion">texte </label><textarea class=mainForm name=field_18 id=field_18 rows=5 cols=40></textarea></li>
<li class="mainForm" id="fieldBox_19"><label class="formFieldQuestion">fichier </label><input class=mainForm type=file name=field_19 id=field_19 value=""></li>
<!-- end of this page -->
<!-- page validation -->
<SCRIPT type=text/javascript>
<!--
function validatePage1()
{
retVal = true;
if (validateField('field_1','fieldBox_1','text',1) == false)
retVal=false;
if (validateField('field_2','fieldBox_2','text',1) == false)
retVal=false;
if (validateField('field_3','fieldBox_3','text',1) == false)
retVal=false;
if (validateField('field_4','fieldBox_4','email',1) == false)
retVal=false;
if (validateField('field_5','fieldBox_5','text',1) == false)
retVal=false;
if (validateField('field_6','fieldBox_6','text',1) == false)
retVal=false;
if (validateField('field_7','fieldBox_7','text',1) == false)
retVal=false;
if (validateField('field_8','fieldBox_8','email',1) == false)
retVal=false;
if (validateField('field_9','fieldBox_9','text',1) == false)
retVal=false;
if (validateField('field_10','fieldBox_10','menu',0) == false)
retVal=false;
if (validateDate('field_11','fieldBox_11','date',1,'','') == false)
retVal=false;
if (validateField('field_12','fieldBox_12','text',1) == false)
retVal=false;
if (validateField('field_13','fieldBox_13','text',1) == false)
retVal=false;
if (validateField('field_14','fieldBox_14','checkbox',0) == false)
retVal=false;
if (validateField('field_15','fieldBox_15','checkbox',0) == false)
retVal=false;
if (validateField('field_16','fieldBox_16','checkbox',0) == false)
retVal=false;
if (validateField('field_17','fieldBox_17','checkbox',0) == false)
retVal=false;
if (validateField('field_18','fieldBox_18','textarea',0) == false)
retVal=false;
if (validateField('field_19','fieldBox_19','file',0) == false)
retVal=false;
if(retVal == false)
{
alert('Please correct the errors. Fields marked with an asterisk (*) are required');
return false;
}
return retVal;
}
//-->
</SCRIPT>
<!-- end page validaton -->
<!-- next page buttons -->
<li class="mainForm" id="fieldBox_19">
<label class="formFieldQuestion">
<img src="CaptchaSecurityImages.php" /></label><li class="mainForm">
<label class="formFieldQuestion">
</br><a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox></span></a><BR><BR> </label><input id="captchaForm" name="security_code" class="mainForm" type="text"/>
</li><li class="mainForm">
<input id="saveForm" class="mainForm" type="submit" value="Submit" />
</li>
</form>
<!-- end of form -->
<!-- close the display stuff for this page -->
</ul></div><div id="footer"><p class="footer"><a class=footer href=http://phpformgen.sourceforge.net>Generated by phpFormGenerator</a></p></div>
</body>
</html>
Modifié par totoutarts (29 Jan 2010 - 09:08)