-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
52 lines (45 loc) · 1.87 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
document.addEventListener("DOMContentLoaded", function () {
var toggleInput = document.getElementById('toggleDetails');
var detailsList = document.getElementById('detailsList');
var collapseStandardCleaning = document.getElementById('collapseStandardCleaning');
var bookingForm = document.getElementById('bookingForm');
var submitButton = document.querySelector('.btn');
var cleaningCheckboxes = document.querySelectorAll('.form-check-input[name="cleaningOption"]');
var warningText = document.getElementById('warningText');
toggleInput.addEventListener('change', function () {
if (this.checked) {
detailsList.classList.remove('collapsed');
collapseStandardCleaning.classList.add('show');
} else {
detailsList.classList.add('collapsed');
collapseStandardCleaning.classList.remove('show');
}
updateButtonState();
});
var hideDetailsLabel = document.getElementById('hideDetails');
hideDetailsLabel.addEventListener('click', function (event) {
event.stopPropagation();
detailsList.classList.add('collapsed');
collapseStandardCleaning.classList.remove('show');
updateButtonState();
});
cleaningCheckboxes.forEach(function (checkbox) {
checkbox.addEventListener('change', function () {
updateButtonState();
});
});
function updateButtonState() {
var cleaningCount = 0;
cleaningCheckboxes.forEach(function (checkbox) {
if (checkbox.checked) {
cleaningCount++;
}
});
if (cleaningCount > 1) {
warningText.style.color = "#FF0000"; // Highlight warning text in red
} else {
warningText.style.color = "#024751"; // Reset to default color
}
submitButton.disabled = cleaningCount !== 1;
}
});