I have an input field text which is readonly. I'm using it to display the year quarter. I have another input field which is a start date. I'm using jQuery datepicker for choosing the date.
My problem is that the quarter input field value Q1 then if I choose a start date outside of Q1 I need to display a message below it saying:
The selected start date is not within the quarter
How can I do that?
var datePickerOptions = {
dateFormat: 'dd-M-yy',
changeMonth: true,
changeYear: true
}
/* Initialise the date picker */
if (!$.datepicker.initialized) {
$(document).mousedown($.datepicker._checkExternalClick)
.find(document.body).append($.datepicker.dpDiv);
$.datepicker.initialized = true;
}
$(function() {
$("#startdate").datepicker(datePickerOptions);
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Quartor: <input type="text" id="quartor" readonly value="Q1"></p>
<p>Start Date: <input type="text" id="startdate" placeholder="DD-MMM-YYYY"></p>