Bonjour je viens à vous pour une grosse aide car je nage un peu la.
Voilà j'ai crée un formulaire qui marche bien mais le problème c'est qu'une personne peut envoyer un message sans y n'avoir rien rempli.
Donc s'il vous plait aider moi à trouver la solution pour remédier à tous cela et au mieux du mieux avoir le même système que lors de l'inscription sur ce site c-a-d avoir une image validation, mais ce n'est pas le plus important pour l'instant.
Pour vous aider voici mon code en HTML :
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- /*************************************************************** * Copyright MatchWare A/S * * (do not remove comment - serves as DOM compat dropback @ IE) * ****************************************************************/ -->
<title>contact</title>
<meta content="MatchWare Mediator 9.0" name="GENERATOR">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="" name="description">
<meta content="" name="keywords">
<link type="text/css" href="styles_center.css" rel="stylesheet">
<link type="image/x-icon" href="favicon.ico" rel="shortcut icon">
<link href="contact.html" rel="Next">
<script type="text/javascript" language="javascript" src="md8_history.js"></script>
<script type="text/javascript" language="javascript" src="md8_design.js"></script>
<script type="text/javascript" language="javascript" src="md8lib.js"></script>
<script type="text/javascript" language="javaScript">
var first_page = 'contact.html';
var alignment = 'center';
</script>
</head>
<body style="background-image: url(../fondgif.gif);">
<div style="text-align: left; margin-left: 2px; width: auto; font-family: Adobe Garamond Pro; font-weight: bold;">
<div style="width: auto; margin-left: 40px;"><a target="_top" href="
http://www.laroutedesrestaurants.com"><big><big>ACCUEIL</big></big></a><br>
</div>
<div style="text-align: center;"><big style="color: rgb(153, 51, 153);"><big><big>CONTACT</big></big></big></div>
</div>
<div style="text-align: center;">
<form style="width: auto;" method="post" action="formmail.php">
<table style="background-color: rgb(253, 232, 249); text-align: left; margin-left: auto; margin-right: auto; height: 371px; width: 398px;">
<caption style="font-family: Adobe Caslon Pro Bold;"> <br>
</caption> <tbody>
<tr style="font-family: Adobe Caslon Pro Bold;">
<td style="width: 156px; text-align: left; font-family: Adobe Caslon Pro;"><big>Nom
Restaurant:</big></td>
<td style="width: 191px;"><input name="restaurant" size="30" type="text"></td>
</tr>
<tr style="font-family: Adobe Caslon Pro Bold;">
<td style="width: 156px; font-family: Adobe Caslon Pro;"><big>Votre
Nom:</big></td>
<td style="width: 191px;"><input name="nom" size="30" type="text"></td>
</tr>
<tr style="font-family: Adobe Caslon Pro Bold;">
<td style="width: 156px; font-family: Adobe Caslon Pro;"><big>Ville:</big></td>
<td style="width: 191px;"><input name="ville" size="30" type="text"></td>
</tr>
<tr style="font-family: Adobe Caslon Pro Bold;">
<td style="width: 156px; font-family: Adobe Caslon Pro;"><big>Code
postal:</big></td>
<td style="width: 191px;"><input name="code postal" size="30" type="text"></td>
</tr>
<tr style="font-family: Adobe Caslon Pro Bold;">
<td style="width: 156px; font-family: Adobe Caslon Pro;"><big>Votre
Email:</big></td>
<td style="width: 191px;"><input name="email" size="30" type="text"></td>
</tr>
<tr style="font-family: Adobe Caslon Pro Bold;">
<td style="width: 156px; font-family: Adobe Caslon Pro;"><big>Sujet:</big></td>
<td style="width: 191px;"><input name="title" size="30" type="text"></td>
</tr>
<tr style="font-family: Adobe Caslon Pro;">
<td style="width: 191px;" colspan="2">
<div style="text-align: left;"><big>Commentaires:</big><br>
</div>
<textarea cols="50" rows="6" name="comments"></textarea>
</td>
</tr>
</tbody>
</table>
<br>
<input value="Envoyer" type="submit"> - <input value="Annuler" type="reset"></form>
</div>
</body>
</html>
Et voici mon code PHP:
<?php
$TO = "contact@laroutedesrestaurants.com";
$h = "From: " . $TO;
$message = "";
while (list($key, $val) = each($HTTP_POST_VARS)) {
$message .= "$key : $val\n";
}
mail($TO, $subject, $message, $h);
Header("Location:
http://remerciements.laroutedesrestaurants.com/#page1.html" );
?>
Un grand merci d'avance à tous ceux qui veulent bien me venir en aide.
tout d'abord, l'objet document en javascript correspond au contenu du formulaire, donc si t'appelle ton formulaire document.formulaire, alors pour accéder aux champs, il faudra faire document.document.formulaire
voila pour ceux que ca aiderait
Entre <head> et </head> :
<script language="javascript" type="text/javascript"> function checkBtnRadio() { if(document.getElementById('BtnRadio_1').checked != true && document.getElementById('BtnRadio_2').checked != true) { alert("Faites votre choix !"); return false; } return true; } </script>Et dans le <body> :