forked from ryanmwangi/CalMerger
validate the URL
This commit is contained in:
parent
7c19b8d12c
commit
707e085fe7
1 changed files with 12 additions and 5 deletions
|
@ -28,11 +28,18 @@ const form = document.getElementById('merge-form');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const linkGroupName = document.getElementById('link-group-name').value;
|
const linkGroupName = document.getElementById('link-group-name').value;
|
||||||
const calendarsData = [];
|
const calendarsData = [];
|
||||||
|
let valid = true; // Flag to track URL validity
|
||||||
|
|
||||||
for (let i = 0; i < calendarIndex; i++) {
|
for (let i = 0; i < calendarIndex; i++) {
|
||||||
const prefix = document.getElementById(`prefix-${i}`);
|
const prefix = document.getElementById(`prefix-${i}`);
|
||||||
const override = document.getElementById(`override-${i}`);
|
const override = document.getElementById(`override-${i}`);
|
||||||
const url = document.getElementById(`url-${i}`);
|
const url = document.getElementById(`url-${i}`);
|
||||||
if (prefix && override && url) {
|
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({
|
calendarsData.push({
|
||||||
prefix: prefix.value,
|
prefix: prefix.value,
|
||||||
override: override.checked,
|
override: override.checked,
|
||||||
|
|
Loading…
Add table
Reference in a new issue