Reputation: 2707
I am trying to debug a javascript problem, but the problem happens when submitting a form. I see a javascript error briefly in the console window, then the form gets submitted.
Is there a way to make the default not to submit the form, so I can see the script error before I get sent to the form submit page?
The code is using jquery with a
$('#form').on('submit', function() {
// validation code with script error somewhere
});
Upvotes: 0
Views: 80
Reputation: 46218
$('#form').on('submit', function(e) {
e.preventDefault();
// validation code with script error somewhere
});
Upvotes: 3