<script> function hello() { alert('hello') } </script> <form onsubmit="return false;"> <input type="submit" name="hello" onclick="hello()"> </form>
addEventListenerなら動作する
<form onsubmit="return false;"> <input type="submit" name="hello" id="h"> </form> <script> function hello() { alert('hello') } const h = document.getElementById('h') h.addEventListener('click', hello) </script>