Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap DatePicker inside Modal not working

I have this datepicker inside a modal but not working. I already tried some of the codes i saw in the forum, but none of them is working. Could this be a javascript problem? I am not sure what making it not to show the datepicker,anyone who can help me please thanks enter image description here

<script>
$(document).ready(function() {
    $('#datePicker')
        .datepicker({
            format: 'mm/dd/yyyy'
        })
        .on('changeDate', function(e) {
            // Revalidate the date field
            $('#eventForm').formValidation('revalidateField', 'date');
        });

    $('#eventForm').formValidation({
        framework: 'bootstrap',
        icon: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            name: {
                validators: {
                    notEmpty: {
                        message: 'The name is required'
                    }
                }
            },
            date: {
                validators: {
                    notEmpty: {
                        message: 'The date is required'
                    },
                    date: {
                        format: 'MM/DD/YYYY',
                        message: 'The date is not a valid'
                    }
                }
            }
        }
    });
});
</script>
<div class="form-group">
        <label class="col-xs-3 control-label">Date</label>
        <div class="col-xs-5 date">
            <div class="input-group input-append date" id="datePicker">
                <input type="text" class="awe-calendar" name="date" />
                <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
            </div>
        </div>
    </div>
like image 773
Kim Ocampo Octaviano Avatar asked Sep 25 '15 09:09

Kim Ocampo Octaviano


2 Answers

add z-index above 1051 in class datepicker

add something like this in page or css

<style>
  .datepicker{z-index:1151 !important;}
</style>
like image 177
RiesvGeffen Avatar answered Sep 29 '22 08:09

RiesvGeffen


The same issue i faced, the best method is please check the below code which i used to fix this issue. This will work wen you click any where in the body

Please add the just above of

div model-body

    <script>
      $(document).on("click", ".modal-body", function () {
       $("#datepicker").datepicker({
         dateFormat: 'yy-mm-dd'                                    
         });
          });  
    </script> 
 <div class="modal-body">
like image 42
Abhilash Thomas Avatar answered Sep 29 '22 06:09

Abhilash Thomas