Bon javascript corrigé par un ami par contre pour la partie transfert entre le javascript et le php! Mystère !!!
Je ne reçois jamais le mail !!
le .js corrigé :
$(function() {
// load the modal window
$(‘a.modal’).click(function(){
// scroll to top
$(‘html, body’).animate({scrollTop:0}, ‘fast’);
// before showing the modal window, reset the form incase of previous use.
$(‘.success, .error’).hide();
$(‘form#contactForm’).show();
// Reset all the default values in the form fields
$(‘#name’).val(‘Votre nom et prénom’);
$(‘#email’).val(‘Votre adresse mail’);
$(‘#comment’).val(‘Votre demande/message…’);
$(‘#ville’).val(‘Votre ville’);
$(‘#telephone’).val(‘Votre numéro’);
//show the mask and contact divs
$(‘#mask’).show().fadeTo( », 0.7);
$(‘div#contact’).fadeIn();
// stop the modal link from doing its default action
return false;
});
// close the modal window is close div or mask div are clicked.
$(‘div#close, div#mask’).click(function() {
$(‘div#contact, div#mask’).stop().fadeOut(‘slow’);
});
$(‘#contactForm input’).focus(function() {
// $(this).val(‘ ‘); <– celui là, il était traitre !
$(this).val('');
});
$('#contactForm textarea').focus(function() {
$(this).val('');
});
// when the Submit button is clicked…
$('input#submit').click(function() {
$('.error').hide().remove();
//Inputed Strings
var username = $('#name').val();
var email = $('#email').val();
var ville = $('#ville').val();
var telephone = $('#telephone').val();
var comment = $('#comment').val();
//Error Count
// var error_count;
var error_count = 0;
//Regex Strings
// var username_regex = /^[a-z0-9_-]{3,16}$/, //Original
var username_regex = new RegExp('^[ a-zéèàùçÇêÉÈÀÙôÔâÂîÎ0-9_-]{3,32}$','i'); // une erreur ici : la ligne était finie par une virgule, au lieu d'un point virgule… J'ai ajouté les majuscules et espaces au masque de contrôle, et allongé la limite, car le formulaire indique Nom & Prénom, 16 caractères, ça peut être trop court…
// email_regex = /^([a-z0-9_\.-]+)@([a-z0-9\.-]+)\.([\ba-z\.]{2,6})$/; //Original
var email_regex = new RegExp('^([a-z0-9_\.-]+)@([a-z0-9\.-]+)\.([\ba-z\.]{2,6})$', 'i'); //Original
//Test Username
if(!username_regex.test(username)) {
$('#contact_header').after('Nom invalide !’ + username);
error_count += 1;
}
//Test Email
if(!email_regex.test(email)) {
$(‘#contact_header’).after(‘Erreur de mail !’ + email);
error_count += 1;
}
//Blank Comment?
if(comment == ») {
$(‘#contact_header’).after(‘Aucun commentaire écris !’);
error_count += 1;
}
//No Errors?
if(error_count === 0) {
$.ajax({
type: « post »,
url: « send.php »,
// data: « $name= » + name + « &email= » + email + « $ville » + ville + « $telephone » + telephone + « &comment= » + comment, //ORIGINAL
data: « name= » + name + « &email= » + email + « &ville= » + ville + « &telephone= » + telephone + « &comment= » + comment,
error: function(return_val) {
//DEVMODE alert(‘error : ‘+return_val);
$(‘.error’).hide();
$(‘#sendError’).slideDown(‘slow’);
},
success: function (return_val) {
//DEVMODE alert(‘success : ‘+return_val);
$(‘.error’).hide();
$(‘.success’).slideDown(‘slow’);
$(‘form#contactForm’).fadeOut(‘slow’);
}
});
}
else {
$(‘.error’).show();
}
return false;
});
});