$(document).ready(function(){
$("#sendmail").click(function(){
var valid = '';
var isr = ' est requis.';
var name = $("#name").val();
var mail = $("#mail").val();
var subject = $("#subject").val();
var text = $("#text").val();
if (name.length<1) {
valid += '
Votre nom'+isr;
}
if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
valid += '
Un email valide'+isr;
}
if (subject.length<1) {
valid += '
Un objet'+isr;
}
if (text.length<1) {
valid += '
Un message'+isr;
}
if (valid!='') {
$("#response").fadeIn("slow");
$("#response").html("Erreur:"+valid);
}
else {
var datastr ='name=' + name + '&mail=' + mail + '&subject=' + subject + '&text=' + text;
$("#response").css("display", "block");
$("#response").html("Envoi message .... ");
$("#response").fadeIn("slow");
setTimeout("send('"+datastr+"')",2000);
}
return false;
});
});
function send(datastr){
$.ajax({
type: "POST",
url: "mail.php",
data: datastr,
cache: false,
success: function(html){
$("#response").fadeIn("slow");
$("#response").html(html);
setTimeout('$("#response").fadeOut("slow")',2000);
}
});
}