How to Disable click outside of bootstrap modal area to close modal?

Total Post:52

Points:366
C#
 1051  View(s)
Ratings:
Rate this:
I am designing a website through bootstrap, with a couple of Bootstrap 'Modals'. I have Problem, I can close the modal by clicking on the background. Is there any way to disable this feature?
Please help!!!
  1. Post:110

    Points:774
    Re: How to Disable click outside of bootstrap modal area to close modal?


    If you opening the modal by js, use:

    $('#myModal').modal({backdrop: 'static', keyboard: false})  

     

     

    If you are using data attributes, use:

     

    <div id="Mymodal-Create" class="modal fade
    bd-example-modal-lg"
    tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false" aria-labelledby="myLargeModalLabel" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title">Create
                            </h4>
                        </div>
                        <div class="modal-body" id="Create-Body">
                        </div>
     
                        <div class="modal-footer">
                            <input type="Submit" class="btn btn-primary" id="btnsubmit"  value="Add" />
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                                Close
                            </button>
     
                        </div>
     
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
     
            </div>

     

     

      Modified On Apr-11-2018 10:48:14 PM

Answer