function check(){
    var ok = true;
    var msg = "";
    //alert(document.formulaire.titre.value);
    var regexNom = /^[A-Za-z-' ]{1,}$/;
    if(document.formContacts.nom.value=="" || !regexNom.test(document.formContacts.nom.value)){
        ok = false;
        msg += "\n -Nom";
    }
    var regexPrenom = /^[a-zA-Z0-9ÀÂÇÈÉÊËÎÔÙÛàâçèéêëîôùû -]{1,}$/;
    if(document.formContacts.prenom.value=="" || !regexPrenom.test(document.formContacts.prenom.value)){
        ok = false;
        msg += "\n -Prénom";
    }
    var regexSociete = /[^\#\<\>]{1,}$/;
    if(document.formContacts.societe.value=="" || !regexSociete.test(document.formContacts.societe.value)){
        ok = false;
        msg += "\n -Société";
    }
    var regexMail = /^[a-zA-Z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/;
    if(document.formContacts.mail.value=="" || !regexMail.test(document.formContacts.mail.value)){
        ok = false;
        msg += "\n -Email";
    }
    var regexMessage = /[^\#\<\>]{1,}$/;
    if(document.formContacts.message.value=="" || !regexMessage.test(document.formContacts.message.value)){
        ok = false;
        msg += "\n -Message";
    }
    //
    if(ok==true){

        //création de variable qui récupère les champs fu formulaire de contact
        var nom = $("#formContacts input[name=nom]").val();
        var prenom = $("#formContacts input[name=prenom]").val();
        var societe = $("#formContacts input[name=societe]").val();
        var mail = $("#formContacts input[name=mail]").val();
        var contacts = $("#formContacts select").val();
        var message = $("#formContacts textarea").val();

        //envoi des informations du formulaire en Ajax
        $.post("index.php?page=contacts", {
            nom: nom,
            prenom: prenom,
            societe:societe,
            mail:mail,
            contacts:contacts,
            message:message
        },
        function(data){
            //permet de vider tous les champs du formulaire après l'envoi des informations'
            $("#formContacts input, #formContacts textarea").each(function(){
                $(this).val("");
            });
            $("#formContacts select").val("Defametal");

            //affichage de la notification indiquant que le mail est bien parti
            //le code qui suit est en relation avec les balises <script> dans le fichier head.tpl pour afficher la notifcation
            $.gritter.add({
                // (string | mandatory) the heading of the notification
                title: "Merci d'avoir rempli le formulaire.",
                // (string | mandatory) the text inside the notification
                text: "Votre mail nous est parvenu.<br />Nous vous répondrons dans les meilleurs délais. "
            });
        });

        return false;
    }else{
        alert("Merci de remplir correctement les champs suivants :\n"+msg);
        return false;
        
    }

}
