...

/

Datepickers, Dropdowns, and Host Card

Datepickers, Dropdowns, and Host Card

Learn how to add datepickers and dropdowns to the web layouts.

Make the changes

Here's a live code environment to try the changes suggested in the lesson.

Datepickers

There is an interesting website called Gijgo, that has a daterange picker example. We’ll use the example code and integrate it into our theme.

Here is the code we copied from the example.

Press + to interact
<head>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link href="https://unpkg.com/gijgo@1.9.13/css/gijgo.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
Start Date: <input id="startDate" width="276" /> End Date: <input id="endDate" width="276" />
</div>
<script src="https://unpkg.com/gijgo@1.9.13/js/gijgo.min.js" type="text/javascript"></script>
<script>
let
today = new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate()
);
$('#startDate').datepicker({
uiLibrary: 'bootstrap4',
iconsLibrary: 'fontawesome',
minDate: today,
maxDate: function () {
return $('#endDate').val();
}
});
$('#endDate').datepicker({
uiLibrary: 'bootstrap4',
iconsLibrary: 'fontawesome',
minDate: function () {
return $('#startDate').val();
}
});
</script>
</body>

Note that for the datepicker to work, we had to move the jQuery ...