User:Pmw57/form-handling-techniques
Appearance
Forms can be accessed either via the forms collection, or a unique identifier. Using a unique id for the form is an effective technique that allows good flexibility as to how the form is accessed and worked with from the scripting.
<form id="login">
<p><label>Username <input name="username"></p>
<p><label>Password <input name="password"></p>
</form>
You can attach a scripting event to the form with:
var form = document.getElementById('login');
form.onclick = function () {
...
};