event.preventDefault()
prevents the browser from executing the default action associated with the event. For a submit button, the default action is sending the form data and reloading the page. By calling preventDefault()
inside a submit handler, you stop the form from submitting normally, allowing you to handle the submission with JavaScript instead, such as validating the input, sending the data via AJAX, or updating the page dynamically without a full reload.