Yet another datepicker jQuery plugin easily used in Bootstrap modal popup. The plugin has multi options, multi functions and multi languages to pick current, selected or filtered date.
Plugin Preview
How to start using jQuery?
More jQuery Top, Best and New Plugins
Top 100 jQuery Plugins
Plugin Overview
Plugin: | datepicker-in-bootstrap-modal |
Author: | Fengyuan Chen |
Licence: | MIT Licence |
Published: | March 1, 2024 |
Repository: | Fork on GitHub |
Dependencies: | jQuery 3.3.1 or Latest version, Bootstrap 4.1.3 |
File Type: | zip archive (HTML, CSS & JavaScript) |
Package Size: | 38 KB |
How to Use Datepicker in Bootstrap Modal:
1. To getting started with this plugin, load the jQuery and Bootstrap framework.
<!-- jQuery --> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"> <!-- Bootstrap Js --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
2. After this, include the datepicker’s javascript and CSS files.
<!-- Datepicker CSS --> <link rel="stylesheet" href="css/datepicker.css"> <!-- Datepicker JS--> <script src="js/datepicker.js"></script>
3. To create Bootstrap datepicker in modal popup, so build the HTML structure like below.
<!-- Button trigger modal --> <button type="button" class="btn btn-primary" data-target="#modal" data-toggle="modal"> Launch the demo </button> <!-- Modal --> <div class="modal fade" id="modal" role="dialog" aria-labelledby="modalLabel" tabindex="-1"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="modalLabel">Datepicker</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body" style="height: 1000px;"> <input type="text" class="form-control" data-toggle="datepicker"> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div>
4. Initialize the plugin in jQuery document ready function so that datepicker activated.
$(function() { $('[data-toggle="datepicker"]').datepicker({ autoHide: true, zIndex: 2048, }); });
Similar Code Snippets:
I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences.
I truly enjoy what I’m doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.
datepicker is not a function
how to solve this error
Hi Nadhir!
Please make sure date picker plugin file loading properly.
Unfortunately, my datepicker continue showing under the modal. Any ideas?
Hi Dayana!
Make sure your modal has minimum height that can contain the datepicker.