I am trying to use jQuery Validation plugin on my website. I need to validate two separate forms and use ajax to submit them to two different PHP pages. I am new to JavaScript, but have done a lot of research regarding this, however, I am still stuck.
This is what I have come up with so far... How can I validate and submit one form to processA.php and the second form to processB.php. Each form has different fields. Is it possible to add a second submitHandler?
$("form").each(function() {
$(this).validate({
submitHandler: function(form) {
$.ajax({
type : 'POST',
url : 'processA.php',// write code to send mail in mail.php
data : $(form).serialize(),
cache : false,
dataType: 'text',
success : function (serverResponse) {
alert('mail sent successfully.');
},
error : function (jqXHR, textStatus, errorThrown) {
alert('error sending mail');
}
});
return false; // Temporary
}
});
});
{}button to format a block of code.