Step 4

Let's create a script.js file with the following content and link it to the index.html.

const submitBtn = document.getElementById("submit");
submitBtn.addEventListener("click", handleFormSubmit);

function handleFormSubmit(event) {
  event.preventDefault();
  window.alert("Thanks for the payment!");
}

The preventDefault() method, when called in response to clicking on a "Submit" button, prevents it from submitting a form.