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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| <html>
<BODY>
<script>
//verification du formulaire:
function couleur(objet){
objet.style.backgroundColor = "#ff0033";
}
function check (formulaire){
var msg = "";
//verification du champ mail, du . et du @
if(formulaire.mail.value != ""){
indexArob = formulaire.mail.value.indexOf('@');
indexPoin = formulaire.mail.value.indexOf('.');
if(indexArob<0 ||indexPoin<0){
formulaire.mail.style.backgroundColor = "#F4811F";
msg+= "veuillez renseigner le champ e-mail\n";
}
}else{
formulaire.mail.style.backgroundColor = "#F4811F";
msg+= "veuillez renseigner le champ e-mail\n";
}
//vérification du champ web:
if(formulaire.www.value !=""){
indexWWW=formulaire.www.value.indexOf('www');
indexExtention=formulaire.www.value.indexOf('.');
if(indexWWW<0 || indexExtention<0){
formulaire.www.style.backgroundColor = "#F4811F";
msg+="veuillez renseigner le champ site\n";
}
}else{
formulaire.www.style.backgroundColor = "#F4811F";
msg+="veuillez renseigner le champ site\n";
}
//vérification du champ text:
if(formulaire.text.value == ""){
formulaire.text.style.backgroundColor = "#F4811F";
msg+="veuillez renseigner le champ message\n";
}
//vérification du champ tel:
if(formulaire.tel.value !=""){
ok = new RegExp("^([0-9])+$","gi");
//les carateses autorisés "0123456789"
if (!ok.test(formulaire.tel.value) ){
formulaire.tel.style.backgroundColor = "#F4811F";
msg+="veuillez renseigner le champ téléphone\n";
}
}else{
formulaire.tel.style.backgroundColor = "#F4811F";
msg+="veuillez renseigner le champ téléphone\n";
}
//tous les champs sont vérifiés. si la var msg est vide, on envoie le formulaire, sinon on pointe les champs mal renseignés et on envoie un message d'alerte
if(msg==""){return true;}
else{
alert (msg);
return false;
}
}//fin de la fonction check
</script>
//formulaire:
<form action="mail.php" method="post" target="_self"
enctype="application/x-www-form-urlencoded" onsubmit="return check(this);" >
<input type="hidden" name="destinataire" value="nina_bee@hotmail.fr" id="destinataire"/>
<input type="hidden" name="objet" value="contact client" id="objet" />
<p>
<label for="mail" class="formText">Votre adresse e-mail professionnelle: </label><br>
<span class="champs" name="champ">
<input name="mail" style="" type="text" id="mail" size="40" onkeyup="javascript:couleur(this);" />
</span></p>
<p>
<label for="www" class="formText">Votre site web entreprise:</label><br>
<span class="champs" >
<input name="www" style="" type="text" id="www" size="40" onkeyup="javascript:couleur(this);" />
</span> </p>
<p>
<label for="text" class="formText">Votre message: </label><br>
<span class="champs">
<textarea name="text" style="" cols="40" rows="15" id="text" onkeyup="javascript:couleur(this);" ></textarea>
</span>
</p>
<p>
<label for="tel" class="formText">Votre numéro de téléphone : </label><br>
<span class="champs" name="champ">
<input name="tel" style="" type="text" id="tel" size="40" onkeyup="javascript:couleur(this);" />
</span>
</p>
<p align="right" class="formText"><input type="submit" value="envoi" name="submit" /></p>
</form>
</body>
</html> |
Partager