JSFiddle - React, Tailwind, and code Playground
HTML
<form id="panda" method="post">
<input type="submit" value="The Panda says..."/>
</form>
JavaScript
// your function
var my_func = function(event) {
alert("me and all my relatives are owned by China");
event.preventDefault();
};
// your form
var form = document.getElementById("panda");
// attach event listener
form.addEventListener("submit", my_func, true);