Accessing the Form
var theForm = document.forms;
<form name="someform" ...> ... var theForm = document.someform;
As discussed in earlier chapters, there are also a couple of ways to intercept a form before submitting it to the server. The event you're going for is submit on the form. However, you can trap the submit event using an inline event handler, a traditional handler, or the addEventListener/attachEvent option. The key is that once you've validated the form contents, you need to be able to cancel the event if the contents fail. In the next section, we'll look at how to attach an event handler and cancel a form submittal, based on the different event-handling approaches.