Bonjour,
J'ai créé un formulaire de contact pour mon site internet.
Il fonctionne, cependant j'aimerais savoir où renseigner le mail du destinataire du formulaire (à savoir moi) pour que je recoive le mail quand on clique sur le bouton "GO".
Voici mon code HTML :
<!-- CONTACT FORM -->
<div id="contact_form">
<!-- Name -->
<input type="text" name="name" value="NOM *" id="form-name" />
<!-- Email -->
<input type="text" name="mail" value="EMAIL *" id="form-mail" />
<!-- Message (textarea) -->
<textarea name='message' rows="5" cols="62" id="form-message">MESSAGE *</textarea>
<!-- Button -->
<button type="submit" id="button" >Go</button>
<!--container for the results of mail.php-->
<div id="result"></div>
</div>
<!-- END CONTACT FORM -->
et mon code javascript :
/* 11. Validate contact form
==========================================*/
var name_value = 'NOM *'; //default placeholder text for the name field
var mail_value = 'EMAIL *'; //default placeholder text for the email field
var message_value= 'MESSAGE *'; //default place holder text for the textarea
var missing_name = 'Entrez votre nom SVP'; //error message, if the name field is empty
var missing_mail = 'Renseignez votre adresse mail SVP'; //error message, if the mail field is empty
var invalid_mail = 'Adresse mail invalide'; //error message, if the user's email address is invalid
var missing_message = 'Entrez votre message SVP'; //error message, if the textarea is empty
var error_color = '#990000'; //text color of the error messages
var default_color = '#333333'; //default text color of the contact form
$('input#form-name').click(function() {
var form_name = $('input#form-name').val();
if (form_name == missing_name)
{
$('input#form-name').css("color" , default_color);
$('input#form-name').val();
}
else if (form_name == name_value)
{
$('input#form-name').val();
$('input#form-name').css("color" , default_color);
}
});
$('input#form-mail').click(function() {
var form_mail = $('input#form-mail').val();
if (form_mail == missing_mail || form_mail == invalid_mail)
{
$('input#form-mail').css("color" , default_color);
$('input#form-mail').val();
}
else if (form_mail == mail_value)
{
$('input#form-mail').val();
$('input#form-mail').css("color" , default_color);
}
});
$('textarea#form-message').click(function() {
var message_content = $('textarea#form-message').val();
if (message_content == missing_message || message_content == message_value)
{
$('textarea#form-message').css("color" , default_color);
$('textarea#form-message').val('');
}
});
$('#contact_form button#button').click(function() {
var name = $('input#form-name').val();
var email = $('input#form-mail').val();
var telephone = $('input#form-telephone').val();
var comments = $('textarea#form-message').val();
if (name == "" || name == missing_name || name == name_value)
{
$('input#form-name').css("color" , error_color);
$('input#form-name').val(missing_name);
return false;
}
if (email == "" || email == invalid_mail || email == mail_value)
{
$('input#form-mail').css("color" , error_color);
$('input#form-mail').val(missing_mail);
return false;
}
var atpos=email.indexOf("@");
var dotpos=email.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
{
$('input#form-mail').css("color" , error_color);
$('input#form-mail').val(invalid_mail);
return false;
}
if (comments == "" || comments == message_value || comments == missing_message)
{
$('textarea#form-message').css("color" , error_color);
$('textarea#form-message').val(missing_message);
return false;
}
$("div#contact_form input[type='text']").remove();
$('div#contact_form textarea').remove();
$('div#contact_form button').remove();
$('div#result').append('<div id="loading"></div>');
$.ajax({
type: 'post',
url: 'mail.php',
data: 'name=' + name + '&email=' + email + '&comments=' + comments,
success: function(results) {
$('div#loading').remove();
$('div#result').html(results);
$(".success a").click(function(){ $("div.success").fadeOut("slow"); return false; });
$(".error a").click(function(){ $("div.error").fadeOut("slow"); return false; });
}
});
});//send click process ends here
Merci de m'aider, je galère dessus depuis 20h !