Calling form.submit() directly skips the browser's constraint validation and does not dispatch the submit event. When code needs the same behavior as activating a submit button, use requestSubmit().
const form = document.querySelector("form");
form.requestSubmit();Pass a button when its settings matter
- requestSubmit(button) uses that button's formaction, formmethod, and related submitter settings.
- Native required, type, and other constraints are checked before the submit event fires.
- Use the submit event for application logic that should run for both keyboard and scripted submission.
Do not remove the user's feedback
If validation fails, the browser can focus the invalid field and expose its message. Keep labels and error text clear, and avoid handling a failed validation as if the form had been submitted.
Test with an empty required field, a valid form, and more than one submit button. The browser's native path is usually less code and more predictable.
