Skip to content

Commit

Permalink
Merge branch 'main' into navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
hars-21 authored Aug 9, 2024
2 parents 11be0c6 + 2130ff9 commit eac0d67
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 227 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,4 @@ <h3 class="instructions-heading" style="text-decoration: underline">

<script src="https://cdn.jotfor.ms/s/umd/latest/for-form-embed-handler.js"></script>
</body>

</html>
11 changes: 4 additions & 7 deletions js/validation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
document.addEventListener("DOMContentLoaded", () => {
const rowsInput = document.getElementById("rows");
const columnsInput = document.getElementById("columns");
const playersInput = document.getElementById("players-count");
const startBtn = document.querySelector(".start-btn");
const validationMessage = document.getElementById("validation-message");
Expand All @@ -19,21 +17,19 @@ document.addEventListener("DOMContentLoaded", () => {
};

const validateAllInputs = () => {
const invalidRows = !validateInput(rowsInput, 5, 30);
const invalidColumns = !validateInput(columnsInput, 5, 30);
const invalidPlayers = !validateInput(playersInput, 2, 6);

if (invalidRows || invalidColumns || invalidPlayers) {
if (invalidPlayers) {
startBtn.disabled = true;
startBtn.classList.add("disabled");
showValidationMessage(true);
} else {
startBtn.disabled = false;
startBtn.classList.remove("disabled");
showValidationMessage(false);
}
};

rowsInput.addEventListener("input", validateAllInputs);
columnsInput.addEventListener("input", validateAllInputs);
playersInput.addEventListener("input", validateAllInputs);

startBtn.addEventListener("click", (event) => {
Expand All @@ -43,5 +39,6 @@ document.addEventListener("DOMContentLoaded", () => {
});

// Initial validation

validateAllInputs();
});
Loading

0 comments on commit eac0d67

Please sign in to comment.