Need some help with a #jQuery issue. Can someone look at this - http://bit.ly/avGLl4 - and tell me where I went wrong?
A:
Use the validate approach like:
var v = jQuery("#newsletterForm").validate({
submitHandler: function(form) {
var str = $("#newsletterForm").serialize();
$.ajax({
type: "POST",
url: "/_addNewsletterUser.php",
data: str,
success: function() {
$('#newsletter_form').hide();
$('#thankyounewsletter').show();
}
});
return false;
}
});
Pentium10
2010-02-06 17:07:24
May want to note that this requires the validation plugin: http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Nick Craver
2010-02-06 17:08:58
This is nice but there remains the question of why the handler in the original question, which certainly looks like it should return false, is not preventing the form submission from continuing.
Pointy
2010-02-06 17:20:14
@Pointy: It only validates, I tried it but wanted my error messages to have a custom look. Not sure I want to use that...was planning on it initially but I don't want to use it for this project.
pxjunkie
2010-02-06 18:39:28
Thanks guys... went through the code line by line and it works now...
pxjunkie
2010-02-06 23:29:36
A:
$('#MyForm').submit(function(e){
e.preventDefault();
...
i'd try that.
Brandon H
2010-02-06 18:33:19