disable to date input, auto caculate
Some checks failed
Deploy static content to Pages / deploy (push) Has been cancelled

This commit is contained in:
2026-03-22 01:23:07 +05:00
parent 727bbb4d0b
commit 575aefb491
2 changed files with 14 additions and 11 deletions

22
app.js
View File

@@ -129,14 +129,20 @@ function renderTemplate(templateId) {
}
}
// Set default dates (today and 1 year from today)
// Set default dates (today and 1 year from today minus 1 day)
function setDefaultDates() {
const today = new Date();
const nextYear = new Date(today);
nextYear.setFullYear(nextYear.getFullYear() + 1);
fromDateInput.value = formatDateForInput(today);
toDateInput.value = formatDateForInput(nextYear);
updateToDate();
}
// Calculate to date (1 year from from date minus 1 day)
function updateToDate() {
const fromDate = new Date(fromDateInput.value);
const toDate = new Date(fromDate);
toDate.setFullYear(toDate.getFullYear() + 1);
toDate.setDate(toDate.getDate() - 1);
toDateInput.value = formatDateForInput(toDate);
}
// Format date for input field (YYYY-MM-DD)
@@ -176,7 +182,6 @@ function setupEventListeners() {
regNumberInput.addEventListener('input', updatePreview);
fromDateInput.addEventListener('change', updatePreview);
toDateInput.addEventListener('change', updatePreview);
modelNumberInput.addEventListener('input', updatePreview);
chassisNumberInput.addEventListener('input', updatePreview);
engineSerialInput.addEventListener('input', updatePreview);
@@ -196,10 +201,7 @@ function setupEventListeners() {
// From date change updates To date
fromDateInput.addEventListener('change', () => {
const fromDate = new Date(fromDateInput.value);
const toDate = new Date(fromDate);
toDate.setFullYear(toDate.getFullYear() + 1);
toDateInput.value = formatDateForInput(toDate);
updateToDate();
renderTemplate(currentTemplateId);
});
}

View File

@@ -78,7 +78,8 @@
</div>
<div class="form-group">
<label class="form-label" for="toDate">To Date</label>
<input type="date" id="toDate" class="form-input" required>
<input type="date" id="toDate" class="form-input" readonly>
<span class="form-hint">Auto-calculated</span>
</div>
</div>