Button does not submit form
- Published:
Sometimes pressing a button does not result in submitting the form and calling JavaScript handlers of the submit
event of the form.
Possible reasons:
- the button has
button
instead ofsubmit
as its type (the value of thetype
attribute); - the button is outside of the form;
- the form is invalid, but this is unnoticeable:
- the invalid form element is hidden,
- or default styling (the
outline
orbox-shadow
property) for invalid elements (the:invalid
pseudoclass) is reset;
- there was a JavaScript error either before submitting the form or in a handler of the
submit
event.