/** * gestion des formulaires de contact */ $(function(){ // form $("label").click(function(){ var jThis = $(this); jThis.css({visibility:"hidden"}); var jInput = $("input[name='"+jThis.attr("for")+"']"); jInput[0].select(); }); $("input").focusin(function(){ var jThis = $(this); var jLabel = $("label[for='"+jThis.attr("name")+"']"); jLabel.css({visibility:"hidden"}); }); $("textarea").focusin(function(){ this.select(); }); $("input").blur(function(){ var jThis = $(this); if (this.value == ""){ var jLabel = $("label[for='"+jThis.attr("name")+"']"); jLabel.css({visibility:"visible"}); } }); }); function sendForm(){ var jForm = $("form"), vForm = jForm[0] ; // check var vPrenom = vForm.prenom.value, vNom = vForm.nom.value, vMail = vForm.email.value, vService = vForm.service.value ; if ( vPrenom=="" || vNom == "" || vMail == "" || vService == 0){ return alert("Les champs marqués d'une asterisque sont obligatoires"); } // envoi $.post( "/mail/sendmail.php", jForm.formSerialize(), function(data){ if (data == "ok"){ alert ("Merci pour votre message"); vForm.reset(); } else { alert ("Une erreur est survenue lors de l'envoi du message."); } } ); return false; }