Lea Verou 5/19/2018

Never forget type="button" on generated buttons!

Read Original

The author details a perplexing bug where hitting 'Enter' in a form text field, built with the Mavo framework, was deleting items instead of adding them. The root cause was that dynamically generated <button> elements without an explicit type attribute default to 'submit' inside a form. This caused the first button (a delete button) to be triggered on form submission attempts. The article explains the HTML specification quirk and recommends always adding type="button" to library-generated buttons to prevent such issues.

Never forget type="button" on generated buttons!

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

1
ServiceNow and Microsoft Copilot
Marius Sandbu 1 votes
2
The Learning Loop and LLMs
Martin Fowler 1 votes