Modal "dismiss buttons" close the modal when pressing Enter in a form
Created by: wesley-murch
If you use a <button class="close" data-dismiss="modal">×</button>
in a modal dialog (as shown in the docs), and that button is within a <form>
element, pressing ENTER while focused on a form input will close the modal.
Demo: http://jsfiddle.net/CEpCj/4/
Focus on an input and press enter - the modal will close - even if the required fields are left blank. If they are valid, the form won't submit and the modal will still close. The expected behavior would be to submit the form and not close the modal.
A <button>
with no type
is an implied type="submit"
; adding type="button"
does fix the issue - but this still seems like unexpected behavior. It seems to be cross-browser.