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
| function effacer() {
// vider tous les champs.
this.label_01 = "Votre message :";
this.label_02 = "Votre nom :";
this.label_03 = "Votre email :";
this.text1 = label_01;
this.text2 = label_02;
this.text3 = label_03;
this.mailStatus = "Veuillez remplir tous les champs.";
}
function verifMail() {
// fonction de vérification de l'email.
if (text3.length >= 7) {
if (text3.indexOf("@") > 0) {
if ((text3.indexOf("@") + 2) < text3.lastIndexOf(".")) {
if (text3.lastIndexOf(".") < (text3.length - 2)) {
return (true);
}
}
}
}
return (false);
}
function verifMsg() {
// on stocke le message à tester afin de ne pas
// altérer l'affichage pendant le test.
msgCheck = text1;
// vérification et modification des retour de ligne
for (i=0; i<text1.length; i++) {
if (msgCheck.substring(i, 2) == "\r") {
msgCheck = msgCheck.substring(1, i-2) + "\n"
+ (msgCheck.substring(i+2, msgCheck.length - i + 2));
}
}
text1 = msgCheck;
}
function envoyer() {
// fonction générale de vérification et d'envoi du mail.
if ((text2 == "") or (text1 == "") or (text3 == "")) {
mailStatus = "Tous les champs ne sont pas remplis...";
} else {
if (verifMail()) {
verifMsg();
mailStatus = "Le message est en cours d'envoi...";
LoadVars("mail.php", 0, "POST");
mailStatus = "Le message a été envoyé au serveur.";
} else {
mailStatus = "Entrez un email valide";
}
}
}
// vider les champs au démarrage.
effacer(); |
Partager