const correctAnswer = "4"; // Replace with the actual correct answer document.getElementById("answer-form").addEventListener("submit", function (e) { e.preventDefault(); // Prevent the form from submitting const userAnswer = document.getElementById("user-answer").value; if (userAnswer === correctAnswer) { alert("Correct answer! Submitting the form..."); // Programmatically submit the form this.submit(); // 'this' refers to the form element } else { alert("Incorrect answer. Please try again."); } });