From 7c19b8d12c4d205dd914ef6067b9803055c8da06 Mon Sep 17 00:00:00 2001 From: Ryan Mwangi Date: Mon, 21 Oct 2024 19:35:12 +0300 Subject: [PATCH] add function to validate URL format --- script.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index dc48043..a5c6e9b 100644 --- a/script.js +++ b/script.js @@ -3,7 +3,13 @@ const form = document.getElementById('merge-form'); const addCalendarButton = document.getElementById('add-calendar'); const result = document.getElementById('result'); - let calendarIndex = 1; + let alendarIndex = 1; + + // Function to validate URL format + function isValidUrl(url) { + const urlPattern = /^(https?:\/\/[^\s$.?#].[^\s]*)$/; // Regex for URL validation + return urlPattern.test(url); + } addCalendarButton.addEventListener('click', () => { const newCalendar = document.createElement('div');