I have a Bootstrap modal that is working correctly, being triggered by a button:
<button type="button" class="btn btn-info mm" data-toggle="modal" data-target="#mm_modal" data-req="foo">
This modal works with some data from a form. I would like to display an alert and not display the modal at all, if the form data fails validation. How do I do this?
I have tried adding a function:
$('button.mm').click( function(ev)
{
    var req = $(ev.currentTarget).data('req');
    if ( req === 'foo' )
    {
        alert('Foo not supported'); 
        throw new Error('Foo not supported');
    }
}
The alert displays correctly but the throw does not seem to abort execution; the Bootstrap modal goes on to be displayed anyway.
 
     
    