// Wait until the DOM is fully loaded document.addEventListener("DOMContentLoaded", () => { // Get the form element const form = document.getElementById("loginForm"); // Add event listener for form submission form.addEventListener("submit", function (event) { event.preventDefault(); // Prevent form from reloading the page // Get values from input fields const username = document.getElementById("username").value; const password = document.getElementById("password").value; // Get the message display element const message = document.getElementById("message"); // Simple check: hardcoded username and password if (username === "admin" && password === "1234") { message.style.color = "green"; // Set text color to green message.textContent = "Login successful!"; } else { message.style.color = "red"; // Set text color to red message.textContent = "Invalid username or password."; } }); });