[jQuery] bassistance validition plugin & the form plugin
Hi all, I'm stumped on this.
I use Ajax to load a form into the DOM. I use the FORM plugin to
handle the form and the Validation plugin to validate it.
If I load the form, fill out everything completely and click submit,
it works perfect.
However, if I type in bad data, click submit and trigger a validation
error, then fix the error and click submit, it posts the form 2 times.
If i make 2 errors (3 total clicks on submit) - it submits it 3
times.
If I make 3 errors (4 total clicks) - it submits 4 times.
I'm stumped, anyone have any idea? Is it the way I deal with objects
added to the DOM via Ajax?
Here's my compete code. Any help is truly appreciated, my head hurts.
#1 - load in the form
#2 - validate and submit the form
$(document).ready(function() {
$('body').click(function(event) { // the way i'm dealing with items
added to the DOM via Ajax
// #1 - load up the form.
if ($(event.target).is('.partInfo')) {
$("#formContainer").load("form.php");
}
// code to submit the form
if ($(event.target).is('.sendCoMailButton')) { // my form button
var sendCoMail = {
target: '.result',
url: 'include/tab-message-sent.php',
type: 'post'
};
$("#sendCoMailForm").validate({
submitHandler: function(form)
{
$(form).ajaxSubmit(sendCoMail);
}
});
}
});
});