jQuery Validation plugin results in empty AJAX POST
Posted
by user305412
on Stack Overflow
See other posts from Stack Overflow
or by user305412
Published on 2010-03-30T19:14:16Z
Indexed on
2010/03/30
23:33 UTC
Read the original article
Hit count: 342
Hi, I have tried to solve this issue for at couple of days with no luck. I have a form, where I use the validation plugin, and when I try to submit it, it submits empty vars. Now, if I remove the validation, everything works fine. Here is my implementation:
$(document).ready(function(){
$("#myForm").validate({
rules: {
field1: {
required: true,
minlength: 5
},
field2: {
required: true,
minlength: 10
}
},
messages: {
field1: "this is required",
field2: "this is required",
},
errorLabelContainer: $("#validate_msg"),
invalidHandler: function(e, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
$("#validate_div").show();
}
},
onkeyup: false,
success: false,
submitHandler: function(form) { doAjaxPost(form); }
});
});
function doAjaxPost(form) {
// do some stuff
$(form).ajaxSubmit();
return false;
}
As I wrote this does not work when I have my validation, BUT if I remove that, and just add an
onsubmit="doAjaxPost(this.form); return false";
to my HTML form, it works - any clue???
Now here is the funny thing, everything works as it should in Safari, but not in firefox 3.6.2 (Mac OS X)!
© Stack Overflow or respective owner