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

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!!!
Last updated:5/23/2017 12:18:33 AM

1 Answers

Jayden Bell
Jayden Bell

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
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'>
                        <h4 class='modal-title'>Create
                    <div class='modal-body' id='Create-Body'>
                    <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'>
                <!-- /.modal-content -->
            <!-- /.modal-dialog -->