$(document).on('keyup submit click', '#myForm', function(e) {
console.log(e.type);
});
Here e.type returns either click or keyup but not the status of submission. How can I check if the form was submitted?
$(document).on('keyup submit click', '#myForm', function(e) {
console.log(e.type);
});
Here e.type returns either click or keyup but not the status of submission. How can I check if the form was submitted?
The document you attached the handler to, doesn't have a submit event, hence it won't fire.
What you could do though, if not to attach the submit handler to the form, would be to check if the e.target is the actual submit button, e.g. check if it has the type="submit" attribute.
if (e.target.hasAttribute('type') &&
e.target.getAttribute('type').toLowerCase() == 'submit') {...}
With that you could check if the submit button were clicked.
If the submission is called in any other way, you need to watch that.
Do note, if you have a validation function called, the form might not actually be submitted, so if you need to know it were, you need to attach the submit handler to the form.