HTML and CSS Reference
In-Depth Information
Note As is unfortunately all too commonly the case for contemporary HTML fea-
tures, don't expect Internet Explorer support for the multiple attribute for the fore-
seeable future. However, it does work on Windows if another major web browser is
used.
The file input includes an accept attribute, which can in theory be used to restrict
the types of files uploaded; however, in practice it is purely advisory and likely will
be ignored. It accepts a comma-separated list of MIME types pertaining to accept-
able file types, which, for example could look like accept="image/gif,image/
jpeg,image/jpg" . This would advise the browser that the server accepts only GIF
and JPEG images. Even if the browser heeds this attribute, in a production environment
you will need to use a server-side filter to check that the files submitted are in fact the
correct types, since client-side checks of this sort are easily circumvented.
Check boxes
This is the old check box we know and love for gathering input that is either true or false.
Along with text inputs, this is one of the most common input types you are likely to run
into. A checkbox input usually takes the form of a square box that can be checked or
unchecked, but using JavaScript, a third “indeterminate” state can be set that gives the
appearance of neither being in a true or false condition, as shown in Figure 4-7 .
Figure 4-7. Three check boxes: one unchecked and one not, and one in an indeterminate state
The indeterminate state is set through the Boolean indeterminate property on
the checkbox element, like so:
function init() {
document.getElementById("option3").indeterminate
= true;
}
window.onload = init;
This code would be placed in a script (either in a script element on the page or,
preferably, in an external file) and would affect the following HTML snippet:
<input type="checkbox" name="option3" id="option3" />
 
Search WWH ::




Custom Search