Stop creating multiple error dialogs

This commit is contained in:
SinTan1729 2022-11-08 18:39:23 -06:00
parent fab2924250
commit 74e5b5d1c7

View File

@ -74,13 +74,15 @@ const submitForm = () => {
}) })
.then((res) => { .then((res) => {
if (!res.ok) { if (!res.ok) {
if (document.getElementById("errBox") == null) {
controls = document.querySelector(".pure-controls"); controls = document.querySelector(".pure-controls");
errBox = document.createElement("p"); errBox = document.createElement("p");
errBox.setAttribute("id", "errBox"); errBox.setAttribute("id", "errBox");
errBox.setAttribute("style", "color:red"); errBox.setAttribute("style", "color:red");
errBox.innerHTML = "Short URL not valid or already in use"; errBox.innerHTML = "Short URL not valid or already in use!";
controls.appendChild(errBox); controls.appendChild(errBox);
} }
}
else { else {
document.getElementById("errBox")?.remove(); document.getElementById("errBox")?.remove();
longUrl.value = ""; longUrl.value = "";