From 822ccf21858d18ef2a2150826f38ecf465f53e3b Mon Sep 17 00:00:00 2001 From: Ines Trabelsi Date: Sat, 21 Sep 2024 12:39:01 +0200 Subject: [PATCH] fix: issue #2 implement form entries --- starterOnly/index.html | 11 ++++++----- starterOnly/modal.js | 24 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/starterOnly/index.html b/starterOnly/index.html index 25fef80699..1f06c17055 100644 --- a/starterOnly/index.html +++ b/starterOnly/index.html @@ -64,7 +64,7 @@

>
-
+
-
+

-
+
-
+
-
+

A quel tournoi souhaitez-vous participer cette année ?

diff --git a/starterOnly/modal.js b/starterOnly/modal.js index bfa3ba8d2d..7b59f66f34 100644 --- a/starterOnly/modal.js +++ b/starterOnly/modal.js @@ -29,4 +29,26 @@ function closeModal() { modalbg.style.display = "none"; } - +function validate() { + // validate first name field + const firstValue = document.getElementById("first").value; + if (firstValue.length < 2) return false; + // validate last name field + const lastValue = document.getElementById("last").value; + if (lastValue.length < 2) return false; + // validate email field + const emailValue = document.getElementById("email").value; + if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue)) return false; + // validate quantity field + const quantityValue = document.getElementById("quantity").value; + if (quantityValue.length === 0) return false; + // validate that at least one radio button for location is selected + const locationBtns = document.getElementsByName("location"); + let locationSelected = false; + locationBtns.forEach((btn) => locationSelected = locationSelected || btn.checked); + if (!locationSelected) return false; + // validate that the general conditions are read and accepted + const generalConditions = document.getElementById("checkbox1"); + if (!generalConditions.checked) return false; + return true; +}