Ne pas envoyer le formulaire si champs est vide.
Bonjour à tous,
Je suis débutant et j'ai un gros problème.
J'ai cré un site où on peu remplir un formulaire qui m'envoie donc le résultat sur une base SQL.
Le problème c'est qu'il ya des rigolos qui ne remplissent pas le formulaire et me l'envoie vide grrrr comment pourrais-je eviter cela --> donc il faudrait que lorsque un champs n'est pas remplie dans mon formulaire html , il y ai un message erreur
Merci pour votre aide précieux.
voici mon formulaire html
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <html>
<head>
<title>Envoi de fichiers </title>
<base target="_self"></head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<p align=center style='text-align:center'> </p>
<form method="post" action="ajout_tv">
<p align="center"> </p>
<table width="518" border="1" cellspacing="0" align="center" bgcolor="#ECE8DE" bordercolordark="white" bordercolorlight="black">
<tr>
<td width="87" height="26">
<p align="center"><b><font size="2">Déscription</font></b></td>
<td width="431" height="26">
<B><input type="text" name="description" maxlength="100" size="40"></B>
</td>
</tr>
<tr>
<td width="87" height="26">
<p align="center"><b><font size="2">Prix</font></b></td>
<td width="431" height="26">
<B><input type="text" name="prix" maxlength="14" size="40"></B>
</td>
</tr>
<tr>
<td width="87">
<p align="center"><b><font size="2">Prix fixe</font></b></p>
</td>
<td width="431">
<select name="prixfixe" size="1">
<option value="Oui">Oui</option>
<option>Non</option>
<option value="à discuter">à discuter</option>
</select>
</td>
</tr>
<tr>
<td width="87">
<p align="center"><b><font size="2">Tel</font></b></p>
</td>
<td width="431">
<B><input type="text" name="tel" maxlength="20" size="40"></B>
</td>
</tr>
<tr>
<td width="87">
<p align="center"><b><font size="2">émail</font></b></p>
</td>
<td width="431">
<B><input type="text" name="email" maxlength="40" size="40"></B>
</td>
</tr>
<tr>
<td width="87">
<p align="center"><b><font size="2"> </font></b></td>
<td width="431">
<p align="center"><B><input type="submit" name="Submit" value="Envoyer"></B>
</td>
</tr>
</table>
</form>
</body>
</html> |
je suis vraiment un débutant
cela donne ca alors ???
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| <html>
<head>
<title>Envoi de fichiers </title>
<base target="_self"></head>
<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<p align=center style='text-align:center'> </p>
<form method="post" action="ajout_tv">
<p align="center"> </p>
<table width="518" border="1" cellspacing="0" align="center" bgcolor="#ECE8DE" bordercolordark="white" bordercolorlight="black">
<tr>
<td width="87" height="26">
<p align="center"><B><font size="2">Déscription</font></B></td>
<td width="431" height="26">
<B><input type="text" name="description" maxlength="100" size="40"></B>
</td>
</tr>
<tr>
<td width="87" height="26">
<p align="center"><B><font size="2">Prix</font></B></td>
<td width="431" height="26">
<B><input type="text" name="prix" maxlength="14" size="40"></B>
</td>
</tr>
<tr>
<td width="87">
<p align="center"><B><font size="2">Prix fixe</font></B></p>
</td>
<td width="431">
<select name="prixfixe" size="1">
<option value="Oui">Oui</option>
<option>Non</option>
<option value="à discuter">à discuter</option>
</select>
</td>
</tr>
<tr>
<td width="87">
<p align="center"><B><font size="2">Tel</font></B></p>
</td>
<td width="431">
<B><input type="text" name="tel" maxlength="20" size="40"></B>
</td>
</tr>
<tr>
<td width="87">
<p align="center"><B><font size="2">émail</font></B></p>
</td>
<td width="431">
<B><input type="text" name="email" maxlength="40" size="40"></B>
</td>
</tr>
<tr>
<td width="87">
<p align="center"><B><font size="2"> </font></B></td>
<td width="431">
<p align="center"><B><input type="submit" name="Submit" value="Envoyer"></B>
</td>
</tr>
</table>
</form>
<script language="JavaScript">
<!-- Beginning of JavaScript -
function verifier(){
var champs_vides=0;
champs_vides+=(document.mon_formulaire.mon_champ.value.length==0);
if (champs_vides) alert("il existe encore des champs vides");
return champs_vides;
}
// - End of JavaScript - -->
</script>
</body>
</html> |