Add input validation and error handling for clan+player modals.

This commit is contained in:
MaxJa4
2024-01-17 21:08:18 +01:00
parent 5af0f437b0
commit 331f725959
7 changed files with 361 additions and 183 deletions

View File

@@ -12,9 +12,14 @@ function setupClanButtons(dropdownId, delBtnId, editBtnId) {
dropdown.addEventListener('change', function () {
deleteButton.disabled = !this.value;
deleteButton.classList.toggle("bg-secondary-subtle");
editButton.disabled = !this.value;
editButton.classList.toggle("bg-secondary-subtle");
if (this.value) {
deleteButton.classList.remove("bg-secondary-subtle");
editButton.classList.remove("bg-secondary-subtle");
} else {
deleteButton.classList.add("bg-secondary-subtle");
editButton.classList.add("bg-secondary-subtle");
}
});
}
@@ -30,7 +35,10 @@ function setupPlayerButtons(dropdownId, listId, addBtnId) {
dropdown.addEventListener('change', function () {
addButton.disabled = !this.value && (dropdown.selectedIndex !== -1);
addButton.classList.toggle("bg-secondary-subtle");
if (this.value)
addButton.classList.remove("bg-secondary-subtle");
else
addButton.classList.add("bg-secondary-subtle");
});
}