J'ai créé un formulaire et voudrais que tous les champs soient obligatoires.
Ayant suivi les conseils sur le tutoriel nvu modulaire, je crois que j'ai un soucis dans ma programmation car ça ne fonctionne pas. En effet, lorsque je fais un aperçu sur IE et que je rempli mon formulaire de façon incomplète, aucun message d'erreur n'apparait.
Voici ce qui se trouve dans ma source:
Code : Tout sélectionner
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-15"
http-equiv="content-type">
<title>form_ann</title>
<meta content="lou" name="author">
<style title="form_ann" media="all" type="text/css">
body { margin: 12% 5% 10% 44%;
font-family: Verdana;
font-size: 0.8em;
color: rgb(0, 0, 0);
speak: normal;
list-style-image: url();
}
h1 { font-size: 0.9em;
font-family: Georgia;
color: rgb(0, 0, 0);
text-decoration: underline;
speak: normal;
}
p { font-family: Verdana;
font-size: 0.8em;
speak: normal;
}
a { font-family: Verdana;
font-size: 0.8em;
speak: normal;
}
a:hover { font-family: Verdana;
font-size: 0.8em;
speak: normal;
}
</style>
</head>
<body style="direction: ltr;">
<form style="width: 492px;"
onsubmit="verifier_envoi(); return false;" id="essai"
action="essai" enctype="text/plain" name="form_ann">
<!--
function verifier_envoi()
{
var texte='';
for(i=0;i<2;i++)
{
var verifier=document.form_ann.elements[i];
if(!verifier.value)
{
alert('Vous n\'avez pas rempli le champ'+verifier.name+'!');verifier.focus()
return;
}
texte+=verifier.name+':'+verifier.value+'\n';
}
document.form_ann.sortie.value=texte;
}
-->
<h1>Formulaire d'annonce de recherche:</h1>
<br>
<br>
Pseudo:<br>
<input maxlength="80" size="41" name="Pseudo"><br>
<br>
Sujet:<br>
<input maxlength="80" size="41" name="Sujet"><br>
<br>
Votre texte:<br>
<span style="text-decoration: underline;"><textarea
cols="58" rows="10" name="sortie"></textarea></span><br>
<br>
<br>
<br>
<div style="text-align: center;"><input
value="valider" name="valider" type="submit"><input
name="Reinitialiser" value="Reinitialiser" type="reset"><br>
</div>
</form>
</body>
</html>
Message envoyé avec : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)