Hello guys,
i been searching and searching and i cant find a solution everything seems fine to me so help me a bit on this :
First of all i got my .js form like this :
Contact.js
$(document).ready(function(){
$("#submit").click(function(){
$(".error").hide();
var hasError = false;
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var nameVal = $("#name").val();
if(nameVal == '') {
$("#name").after('<span class="error">Porfavor pon tu nombre.</span>');
hasError = true;
}
var emailVal = $("#email").val();
if(emailVal == '') {
$("#email").after('<span class="error">Porfavor por tu email</span>');
hasError = true;
} else if(!emailReg.test(emailVal)) {
$("#email").after('<span class="error">Porfavor pon un email valido.</span>');
hasError = true;
}
var messageVal = $("#message").val();
if(messageVal == '') {
$(".textarea").after('<span class="error">Porfavor pon tu mensaje.</span>');
hasError = true;
}
if(hasError == false) {
$(".button").hide();
$("#loading").append('<img src="img/ajax-loader.gif" alt="Loading" id="loading" />');
$.post("sendEmail.php",
{ name: nameVal, email: emailVal, message: messageVal },
function(data){
$("#sendEmail").slideUp("normal", function() {
$("#sendEmail").before('<h2>Email enviado.</h2>');
});
}
);
}
return false;
});
});
then i have the contact.php that will load it first
</script>
<script type="text/javascript" src="js/contact.js"></script>
so after that code " we are still on contact.php " i have the current form :
</li>
<li><a href="contact.php" class="current">/ Contacto</a></li>
</ul>
</div>
<div id="left_large_page" class="clearfix">
<div class="main_content">
<h1>Contactanos</h1>
<form action="contact.php" method="post" id="sendEmail">
<fieldset>
<label for="name">Nombre*:</label>
<div class="input_bg">
<input type="text" name="name" id="name" value="" />
</div>
<label for="email">Email*:</label>
<div class="input_bg">
<input type="text" name="email" id="email" value="" />
</div>
<label for="message">Mensaje*:</label>
<div class="clearfix">
<div class="textarea"><span class="top"></span>
<textarea name="message" id="message" rows="6" cols=""></textarea>
<span class="bottom" id="bottom_message"></span> </div>
</div>
<a href="#" class="button" id="submit"><span>
<button type="submit"><b>Enviar</b></button>
</span> </a>
<div id="loading"></div>
<p>
<input type="hidden" name="submitted" id="submitted" value="true" />
</p>
</fieldset>
</form>
<p></p>
And finally i ahve my sendemail.php
<?php
$mailTo ='me@email.com';
$email = $_POST['email'];
$name = $_POST['name'];
$subject='New Contact From: '.$name;
$message = $_POST['message'];
mail($mailTo, $subject, $message, "De : ".$email);
?>
how are the files setup :
root/js/content.js
root/content.php
root/sendEmail.php
Any clue of what its mal-function i will be very happy to solve this