Don't prevent form submit when using a submitHander #650

Closed
obecker opened this Issue Feb 25, 2013 · 5 comments

Comments

Projects
None yet
3 participants
@obecker

obecker commented Feb 25, 2013

If I add a submitHandler in the options of the plugin the default form submit is cancelled.
This means I can't use the submitHandler to do some additional logic and then fallback to the default behaviour. IMHO it would be better to use the return value as in the normal jQuery form submit event handler.

Line 68 in the current code would become

var result = validator.settings.submitHandler.call( validator, validator.currentForm, event );

and line 73

return result;

(instead of return false)

@jzaefferer

This comment has been minimized.

Show comment
Hide comment
@jzaefferer

jzaefferer Mar 3, 2013

Collaborator

Makes sense. Will look into that after fixing some 1.11 regressions.

Collaborator

jzaefferer commented Mar 3, 2013

Makes sense. Will look into that after fixing some 1.11 regressions.

@nrambeck

This comment has been minimized.

Show comment
Hide comment
@nrambeck

nrambeck Dec 19, 2014

This update is great, but it does break existing code that assumes that the native submit is prevented. That being the case, it probably should have been part of a minor release instead of a bug fix release (ie. 1.14.x instead of 1.13.1). Many of my form submissions broke after bower updated this plugin from 1.13.0 to 1.13.1.

This update is great, but it does break existing code that assumes that the native submit is prevented. That being the case, it probably should have been part of a minor release instead of a bug fix release (ie. 1.14.x instead of 1.13.1). Many of my form submissions broke after bower updated this plugin from 1.13.0 to 1.13.1.

@nrambeck

This comment has been minimized.

Show comment
Hide comment
@nrambeck

nrambeck Dec 19, 2014

Also, for those confused about how to prevent default submits by validated forms with this new update, you need to return false from your custom submit handler like this:

$("form").validate({
    submitHandler: function(form) {
        // do some stuff here
        return false;
    }
});

Also, for those confused about how to prevent default submits by validated forms with this new update, you need to return false from your custom submit handler like this:

$("form").validate({
    submitHandler: function(form) {
        // do some stuff here
        return false;
    }
});
@jzaefferer

This comment has been minimized.

Show comment
Hide comment
@jzaefferer

jzaefferer Dec 19, 2014

Collaborator

You're right, that shouldn't have gone into a patch release, sorry about that. I could revert to the previous behaviour in a 1.13.2 release, but with 1.13.1 out the door for two months, I suspect that the revert would be just as problematic, since it would break code that relies on the new behaviour.

What do you think?

Collaborator

jzaefferer commented Dec 19, 2014

You're right, that shouldn't have gone into a patch release, sorry about that. I could revert to the previous behaviour in a 1.13.2 release, but with 1.13.1 out the door for two months, I suspect that the revert would be just as problematic, since it would break code that relies on the new behaviour.

What do you think?

@nrambeck

This comment has been minimized.

Show comment
Hide comment
@nrambeck

nrambeck Dec 20, 2014

I'm sure leaving it as is would be best. Just a consideration for future releases. Thanks for the plugin by the way. It's one of the best out there for client side validation.

I'm sure leaving it as is would be best. Just a consideration for future releases. Thanks for the plugin by the way. It's one of the best out there for client side validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment