Setting the onSubmit handler with JavaScript

A common issue -- setting the onSubmit event handler of a form with JavaScript. I mean, it's easy enough to set it with

<form id='theForm' onsubmit="return confirm('Really submit?');">


but here is how to do it with JavaScript

<script type='text/javascript'>
document.getElementyById('theForm').onSubmit =
function() { return confirm('Really submit?'); };
</script>

Comments

Popular posts from this blog

Installing Gentoo with full disk encryption

FreeIPA cluster with containers

ADSL Router Model CT-5367 user and pass (VIVACOM)