Permalink
Browse files

Core: Use return value of submitHandler to allow or prevent form submit

Gives more control to the user over allowing or preventing the native
submit event, instead of always preventing it.

Fixes #650
  • Loading branch information...
jzaefferer committed Sep 23, 2014
1 parent 0cb3c95 commit 8b2f1e09b88d3fbfa997a04111d5ad6df92c0e59
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/core.js
View
@@ -46,7 +46,7 @@ $.extend($.fn, {
event.preventDefault();
}
function handle() {
- var hidden;
+ var hidden, result;
if ( validator.settings.submitHandler ) {
if ( validator.submitButton ) {
// insert a hidden input as a replacement for the missing submit button
@@ -55,11 +55,14 @@ $.extend($.fn, {
.val( $( validator.submitButton ).val() )
.appendTo( validator.currentForm );
}
- validator.settings.submitHandler.call( validator, validator.currentForm, event );
+ result = validator.settings.submitHandler.call( validator, validator.currentForm, event );
if ( validator.submitButton ) {
// and clean up afterwards; thanks to no-block-scope, hidden can be referenced
hidden.remove();
}
+ if ( result !== undefined ) {
+ return result;
+ }
return false;
}
return true;

0 comments on commit 8b2f1e0

Please sign in to comment.