From 3ffd34190f47e30a0a73ec5aefb69ed9524e2f1a Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Mon, 21 Oct 2024 19:41:41 +0300 Subject: [PATCH] correct syntax error --- script.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/script.js b/script.js index 82527b3..096df6a 100644 --- a/script.js +++ b/script.js @@ -29,22 +29,23 @@ const form = document.getElementById('merge-form'); const linkGroupName = document.getElementById('link-group-name').value; const calendarsData = []; let valid = true; // Flag to track URL validity - + for (let i = 0; i < calendarIndex; i++) { const prefix = document.getElementById(`prefix-${i}`); const override = document.getElementById(`override-${i}`); const url = document.getElementById(`url-${i}`); if (prefix && override && url) { // Validate the URL - if (!isValidUrl(url.value)) { - valid = false; // Set flag to false if any URL is invalid - alert(`Invalid URL format for calendar ${i + 1}: ${url.value}`); - } else { - calendarsData.push({ - prefix: prefix.value, - override: override.checked, - url: url.value - }); + if (!isValidUrl(url.value)) { + valid = false; // Set flag to false if any URL is invalid + alert(`Invalid URL format for calendar ${i + 1}: ${url.value}`); + } else { + calendarsData.push({ + prefix: prefix.value, + override: override.checked, + url: url.value + }); + } } } fetch('/merge', {