If you set a form's method to "dialog", a modal can be dismissed by submitting that form. This is convenient as it requires no additional javascript.
"dialog"
When the form is submitted, the modal's returnValue is set to the value of the submit button that was clicked.
returnValue
value
A button can be associated with a form, by setting the button's form attribute to the form's id.
form
id