// get the form object let object = document.getElementById('object') // directly object.onsubmit = function() { myScript }; // or using the addEventListener() method: object.addEventListener("submit", myScript);