How can I trigger one of the two alarms only once?

I have an alarm function that warns of successful and incorrect login, I always want the distress message to be sent, but I want the successful login message to be sent only once. Is it possible? Thanks in advance for your answers. Full code: https://codepen.io/BerkayAkgurgen/pen/xxRxorx

// This is where my alarm goes off
function addfilm(e) {
   const title = titleElement.value.trim();
   const director = directorElement.value.trim();
   const url = urlElement.value.trim();

   if(title === "" || director === "" || url === "") {
   ui.displayMessages("danger","Tüm Alanları Doldurunuz.");
   } else{
       const newFilm = new Film(title,director,url);
       ui.addFilmToUI(newFilm);
       ui.displayMessages("success","Başarılı Giriş.");
   }
   ui.clearInputs(titleElement,directorElement,urlElement);
   e.preventDefault();
}


I have an alarm function that warns of successful and incorrect login, I always want the distress message to be sent, but I want the successful login message to be sent only once. Is it possible? Thanks in advance for your answers. Full code: https://codepen.io/BerkayAkgurgen/pen/xxRxorx

// This is where my alarm goes off
function addfilm(e) {
   const title = titleElement.value.trim();
   const director = directorElement.value.trim();
   const url = urlElement.value.trim();

   if(title === "" || director === "" || url === "") {
   ui.displayMessages("danger","Tüm Alanları Doldurunuz.");
   } else{
       const newFilm = new Film(title,director,url);
       ui.addFilmToUI(newFilm);
       ui.displayMessages("success","Başarılı Giriş.");
   }
   ui.clearInputs(titleElement,directorElement,urlElement);
   e.preventDefault();
}

// This is my alert function
let alert = document.getElementById("alertID");

UI.prototype.displayMessages = function (type, message) {
   const cardBody = document.querySelector(".card-body");
   if (alert == null) {
       alert = document.createElement("div");
       alert.className = `alert alert-${type}`;
       alert.id = "alertID";
       alert.textContent = `${message}`;
       cardBody.appendChild(alert);
   } else {
       alert.className = `alert alert-${type}`;
       alert.textContent = `${message}`;
       document.getElementById("alertID").style.display = 'block';
   }
   setTimeout(function myFunction2() {
       document.getElementById("alertID").style.display = 'none';
   }, 1000)
};