I'm struggling with creating an inline / inline datepicker that won't be clickable - it should only specify dates, behave as read only.
What I am doing is filling the calendar with selected dates from the model, and then I try to make it inaccessible to the user, so the user is not thinner, he can edit anything.
I use eternicode-bootstrap-datepicker - to make it multiple.
So far I have this:
<link rel="stylesheet" href="<c:url value="/resources/js/lib/eternicode-bootstrap-datepicker/css/datepicker3.css" />" /> <script src="<c:url value="/resources/js/lib/eternicode-bootstrap-datepicker/js/bootstrap-datepicker.js"/>"></script> <script type="text/javascript"> $(document).ready(function() { $("#datepicker-inline").datepicker({ multidate : true, todayHighlight : true, }); var dates = []; var i = 0; <c:forEach items="${course.selectedDates}" var="selectedDate"> console.log("${selectedDate}"); dates[i++] = new Date("${selectedDate}"); </c:forEach> $("#datepicker-inline").datepicker('setDates', dates); // something to make it readonly $(".day").click(function(event) { console.log("preventing"); event.preventDefault(); }); }); </script> <div class="col-xs-8"> <h4>Dates</h4> <div id="datepicker-inline"></div> </div>
[Sorry if it is poorly formatted]
As you can see, I am trying to prevent the default click click action in .day on the calendar. The console displays a "warning", but still checks the day as selected.
Do you have an idea how to make it disabled / inactive / readonly?
All readonly topics on how to make <input> read-only, but still able to select a date from a datepicker.
source share