Javascript form.requestSubmit() Method

Browser API Update

The requestSubmit() method can request a form submission. The form will be validated, and will be submitted if it passes validation. Furthermore specific form events will be fired as well.

requestSubmit() is different from the submit() method.

submit() just submits the form. It neither validates the form, nor fires the submit & formdata events.

requestSubmit() acts as if the submit button was clicked. The form will be validated. If validation succeeds, the form is submitted. submit & formdata events are fired as well.

document.querySelector("#demo-form").requestSubmit();

The requestSubmit() method provides a solution for developers who are looking to make their custom submit buttons.

Browser Compatibility

Resources

March 12, 2020

Comments

Loading Comments