NN 2, IE 3
You want to verify that a text box contains one of the following: any text, a number, a string of a fixed length, or an email address.
The field has one or more characters in it.
The value is a number.
The field contains exactly 16 characters.
The field contains a likely email address.
For real-time validation of text box entries, use an
onchange event handler in the
input element and pass a reference to the element
by way of the
this keyword. For example, the
input element could be used for an email
<input type="text" size="30" name="eMail" id="eMail" onchange="isEMailAddr(this)" />
See Recipe 8.3 for an example of how these validation functions can
be linked together in batch validation prior to submitting the form.
The return values from the validation functions are vital for
successful operation triggered by the form's
onsubmit event handler.
Example 8-1 shows a set of fully backward-compatible
text validation functions. All of these functions are to be invoked
by both the
event handler of the text box and
a batch validation function triggered by the
event handler of the enclosing form. All functions are passed references to the form control invoking ...