1
0
Fork 0

add function to validate URL format

This commit is contained in:
Ryan Mwangi 2024-10-21 19:35:12 +03:00
parent 28335713f3
commit 7c19b8d12c
1 changed files with 7 additions and 1 deletions

View File

@ -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');