Datepicker
Use Datepicker plugin to enable input for picking dates
Getting started
You need to include the following javascript file before the end of the body
tag:
<script src="@@path/vendor/vanillajs-datepicker/dist/js/datepicker.min.js"></script>
Datepicker
Use the following markup to create a single datepicker:
<label for="birthday">Birthday</label>
<div class="input-group">
<span class="input-group-text">
<svg class="icon icon-xs" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z" clip-rule="evenodd"></path></svg>
</span>
<input data-datepicker="" class="form-control" id="birthday" type="text" placeholder="dd/mm/yyyy" required>
</div>
Javascript
Initializing the datepicker is fairly straightforward. Here’s how we use it in volt.js
:
var datepickers = [].slice.call(document.querySelectorAll('[data-datepicker]'))
var datepickersList = datepickers.map(function (el) {
return new Datepicker(el, {
buttonClass: 'btn'
});
});
Read more about Vanilla JS Datepicker from the documentation.