Filtering Input in JavaScript 1.2
By Reaz Hoque
Invariably, some visitors will input data incorrectly in HTML forms, so there's no getting around validating the input. You can use CGI for validation, but that requires the user to submit the form and wait until the server confirms the validation. I strongly suggest validating with client-side JavaScript, which allows incorrect input to be flagged to the user immediately.
Changes in JavaScript 1.2 mean that you can filter the input while the user is inputting data. For example, to ensure that a field accepts only numbers, you can create a filter that causes the field not to be affected if the user hits any keys except 0-9. This is an improvement over JavaScript 1.1, in which you had to hit a button for a function to check the field for nonnumeric characters.
The Event Object
The event object exists only in JavaScript 1.2. Like other JavaScript objects, it contains properties. Each property describes a JavaScript event, and is passed as an argument to an event handler when the event occurs. For example, if the mouseDown event occurs in an image object, the event object will contain the type of event, the cursor position, and a field denoting the modifier key pressed at the time of the event.
Table 1 lists all the event handlers in JavaScript 1.2, while