Hi I have a following code, validation part and jquery works perfectly in the code but it dosent send the email
I have jquery.js file in the head section of html and it work perfectly
[code]
We will get back to you soon
<form id="contactform">
<div>
<label for="name">NAME:</label>
<input type="text" name="name" id="name" placeholder="John Doe" />
</div>
<div>
<label for="email">EMAIL:</label>
<input type="text" name="email" id="email" placeholder="[email protected]" />
</div>
<div>
<label for="comment">MESSAGE:</label>
<textarea name="comment" rows="10" cols="50" id="comment"></textarea>
</div>
<input type="submit" name="submit" value="SEND" id="submit" />
</form>
this page does the validation part from php
test.php
[php]
this file does the jquery validation without page refresh
function.js
[code]
$(function(){
$("#emailsend").hide();
$("#submit").click(function(event) {
event.preventDefault();
var emailReg = /^([a-z0-9_.-]+)@([\da-z.-]+).([a-z.]{2,6})$/;
var errors = false;
var name = $(’[name=name]’).val();
var email = $(’[name=email]’).val();
var comment = $(’[name=comment]’).val();
$(’.errors’).remove();
if($("#name").val() == ""){
$("#name").after("<span class= 'errors'> Missing Name </span>");
errors = true;
}
if($("#email").val() == ""){
$("#email").after("<span class= 'errors'> Missing Email </span>");
errors = true;
}else if(!emailReg.test($('#email').val())){
$("#email").after("<span class= 'errors'> Not valid Email </span>");
errors = true;
}
if($("#comment").val() == ""){
$("#comment").after("<span class= 'errors'> Missing Comment </span>");
errors = true;
}
if(errors == true) {
return false;
} else {
input_data = {
“name” : name,
“email” : email,
“comment”: comment,
“submit” : true
}
$.ajax({
type: ‘post’,
url: ‘test.php’,
data: input_data,
dataType: ‘json’,
success: function( msg ) {
$("#ack").html(msg);
$("#contactform").delay(500).slideUp(500);
$("#emailsend").show(700);
},
error: function() {
$("#ack").html(‘ERROR!’);
}
});
}
});
});[/code]