diff --git a/src/js/bouncer/bouncer.js b/src/js/bouncer/bouncer.js index 486e1e9..946132c 100644 --- a/src/js/bouncer/bouncer.js +++ b/src/js/bouncer/bouncer.js @@ -758,9 +758,6 @@ // Only run on matching elements if (!event.target.matches(selector)) return; - // Prevent form submission - event.preventDefault(); - // Validate each field var errors = publicAPIs.validateAll(event.target); @@ -768,12 +765,8 @@ if (errors.length > 0) { errors[0].focus(); emitEvent(event.target, 'bouncerFormInvalid', {errors: errors}); - return; - } - - // Otherwise, submit if not disabled - if (!settings.disableSubmit) { - event.target.submit(); + event.preventDefault(); + return false; } // Emit custom event @@ -781,6 +774,11 @@ emitEvent(event.target, 'bouncerFormValid'); } + // Prevent form submission if disabled + if (settings.disableSubmit) { + event.preventDefault(); + } + }; /** @@ -854,4 +852,4 @@ return Constructor; -}); \ No newline at end of file +});