I'm trying everything to change date format but its not working in my XML file. Here is a part of my code. Can anyone tell me what I'm doing wrong?
<tr >
<td> <label class="col-form-label" for="checkIn">Check-in Date</label></td>
<td> <input id="request_checkIn" type="date" t-options='{"datepicker": {"dateFormat": "dd-mm-yy"}}' name="checkIn"/>
<input id="request_checkInTime" type="time"/> </td>
<td> <label class="col-form-label" for="checkOut">Check-out Date</label></td>
<td> <input id="request_checkOut" type="date" t-options='{"datepicker": {"dateFormat": "dd-mm-yy"}}' name="checkOut"/>
<input id="request_checkOutTime" type="time"/> </td>
</tr>
I also Used script for this.
document.addEventListener('DOMContentLoaded', function() {
const today = new Date().toISOString().slice(0, 10);
// get the check-in and check-out date and time inputs
const request_checkIn = document.getElementById('request_checkIn');
const request_checkOut = document.getElementById('request_checkOut');
const request_checkInTime = document.getElementById('request_checkInTime');
const request_checkOutTime = document.getElementById('request_checkOutTime');
// set the minimum and maximum dates for the check-in and check-out date inputs
request_checkIn.setAttribute('min', today);
request_checkOut.setAttribute('min', today);
request_checkIn.addEventListener('input', function() {
request_checkOut.setAttribute('min', this.value);
});
// validate that the check-out date is greater than the check-in date
request_checkOut.addEventListener('input', function() {
if (this.value < request_checkIn.value) {
alert('End date must be greater than start date');
this.value = request_checkIn.value;
}
});
// validate that the check-out time is greater than the check-in time
request_checkOutTime.addEventListener('input', function() {
if (request_checkOut.value === request_checkIn.value && this.value <= request_checkInTime.value) {
alert('End time must be greater than start time');
this.value = request_checkInTime.value;
}
});
});
I've tried several scripts but none of them is working. Please help me if you tried it and worked in Odoo 16 website module.