Skip to content

Different onSuccess behaviour for different forms #77

Closed
@Magnanimity

Description

@Magnanimity

Hi, me again. :)

Again, not an issue, more of an enquiry. Firstly, I have different forms on one page. This is nothing new. The problem comes in that I do not actually use form submissions (my pages never refresh or redirect). I submit form info via AJAX. So in most cases where I have one form on a page, my jQuery would look something like this:

$(document).ready(function()
{
$.validate({
onSuccess : function()
{
someFunction();
return false;
}
});
});

So on successful validation of a form someFunction() gets called, which submits the info via jQuery AJAX. My problem is that I now have two forms on the same page that must call two different fuctions. Each form has its own unique ID. Is there a way that I can discern which form has just been successfully validated in the onSuccess portion so that I can run the relevant function call? I tried console.info(this) inside the onSuccess part, but the information that I get does not discern which form was just validated.

I initially tried onsubmit="someFunction();" on the form, but when I do that, someFunction() gets called even when the form does not validate successfully, which is why I'm using onSuccess.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions