Bart Veneman

Creator of Project Wallace, analytics for CSS. <noscript>-fanboy. Serverless clearfix engineer. I can lift node_modules twice my own weight.

Request submit instead of submitting a form

HTMLFormElement.requestSubmit() in a nutshell. 👇

Spec: https://t.co/vlsZfoYdQA
MDN: https://t.co/pJcTn6WMPZ#devsheets

Video alt: Form that is not submitting on button click due to failing validations. `submit()` ignores errors and submits – `requestSubmit()` validates first. pic.twitter.com/tJTWt5xEXS

— Stefan Judis (@stefanjudis) February 14, 2020

Using form.requestSumit() is sometimes useful (I don't use form.submit() that often) to let the built-in browser validation kick in before sending off the form to the server.

Tags