mirror of
https://github.com/minoplhy/chhoto-url.git
synced 2024-11-22 09:16:46 +00:00
Stop creating multiple error dialogs
This commit is contained in:
parent
fab2924250
commit
74e5b5d1c7
@ -74,12 +74,14 @@ const submitForm = () => {
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
controls = document.querySelector(".pure-controls");
|
||||
errBox = document.createElement("p");
|
||||
errBox.setAttribute("id", "errBox");
|
||||
errBox.setAttribute("style", "color:red");
|
||||
errBox.innerHTML = "Short URL not valid or already in use";
|
||||
controls.appendChild(errBox);
|
||||
if (document.getElementById("errBox") == null) {
|
||||
controls = document.querySelector(".pure-controls");
|
||||
errBox = document.createElement("p");
|
||||
errBox.setAttribute("id", "errBox");
|
||||
errBox.setAttribute("style", "color:red");
|
||||
errBox.innerHTML = "Short URL not valid or already in use!";
|
||||
controls.appendChild(errBox);
|
||||
}
|
||||
}
|
||||
else {
|
||||
document.getElementById("errBox")?.remove();
|
||||
|
Loading…
Reference in New Issue
Block a user