Lea Verou 2018-05-19

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!

kommentarer

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet