My website features a Bootstrap modal that opens automatically on page load, functioning as intended.
However, I am currently facing an issue where the modal closes if the user clicks outside of it. I want to disable this behavior.
The modal contains a mandatory form that needs to be completed and submitted in order for the modal to close. While I am working on implementing the functionality with the submit button, my priority is to prevent users from closing the modal without filling out the form and submitting it.
Below is the current code snippet:
<script type="text/javascript>
$(window).on('load',function(){
$('#my_modal').modal('show');
$("#my_modal").modal({
backdrop: 'static',
keyboard: false
});
});
</script>
Although the modal successfully opens on page load, I need to ensure that users cannot close it by clicking the X button or outside the modal until they have completed and submitted the required form.