javascript bootstrap modal – cancel closing

Look at here : www.bootply.com/QTTDf3zRgV

In this exemple, if the checkbox is checked, then the modal can’t be closed ( with js/jquery):

$('#myModal').on('hide.bs.modal', function(e){
  if( $('#block').is(':checked') ) {
     e.preventDefault();
     e.stopImmediatePropagation();
     return false; 
   }
});

Leave a Comment