0

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
});
3
  • when your validating, on error return false; Commented Jul 4, 2013 at 21:22
  • @jayharris return false; is overkill for this situation. Commented Jul 4, 2013 at 21:29
  • html5 validation, even one invalid field, will prevent the submit. you can make it valid with js to allow the submit, even call.submit() manually if need be. Commented Jul 4, 2013 at 21:36

1 Answer 1

3
$('#form').on('submit', function(e) {
    e.preventDefault();
    // validation code with script error somewhere
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.