<INPUT>NN all   IE all   HTML all
<INPUT>End Tag: Forbidden
 

An INPUT element is sometimes known as a form control, although not all INPUT elements are visible on the page. For the most part, an INPUT element provides a place for users to enter text, click buttons, and make selections from lists. The data gathered from this interaction can be submitted to a server-side program (when the surrounding FORM element is submitted), or it may be used strictly on the client as a way for users to interact with client-side scripts.

Prior to HTML 4.0, INPUT elements were supposed to be wrapped by a FORM element in all instances. This restriction is loosening up, but Navigator 4 still requires the FORM wrapper in order to render INPUT elements.

The primary attribute that determines the kind of control that is displayed on the page is the TYPE attribute. This attribute can have one of the following values: button, checkbox, file, hidden, image, password, radio, reset, submit, or text. Not all INPUT element types utilize the full range of other attributes; sometimes a single attribute has different powers with different element types. For each attribute of the INPUT element, the listing specifies the types to which it applies. Although the TEXTAREA element has its own tag, it is often treated like another form control.

 
Example
<FORM METHOD=post ACTION="http://www.giantco.com/cgi-bin/query">
First Name: <INPUT TYPE="text" NAME="first" MAXLENGTH=15><BR>
Last Name: <INPUT TYPE="text" NAME="last" MAXLENGTH=25><BR>
ZIP Code: <INPUT TYPE="text" NAME="zip" MAXLENGTH=10><BR>
<INPUT TYPE="reset">
<INPUT TYPE="submit">
</FORM>
 
Object Model Reference
NN [window.]document.formName.inputName
[window.]document.forms[i].elements[i]
IE [window.]document.formName.inputName
[window.]document.forms[i].elements[i]
[window.]document.all.elementID
ACCEPTNN n/a   IE n/a   HTML 4
ACCEPT="MIMETypeList"Optional
 

Specifies one or more MIME types for allowable files to be uploaded to the server when the form is submitted. The predicted implementation of this attribute would filter the file types listed in file dialogs used to select files for uploading. In a way, this attribute provides client-side validation of a file type so that files not conforming to the permitted MIME type is not even sent to the server. The HTML 4.0 specification also has this attribute available in the FORM element. It is unclear whether the implementations in browsers will recognize this attribute in both places.

 
Input Types file
 
Example
<INPUT TYPE="file" ACCEPT="text/html, image/gif" ...>
 
Value
Case-insensitive MIME type (content type) value. For multiple items, a comma-delimited list is allowed.
 
Default None.
ACCESSKEYNN n/a   IE 4   HTML 4
ACCESSKEY="character"Optional
 

A single character key that brings focus to the input element. The browser and operating system determine if the user must press a modifier key (e.g., Ctrl, Alt, or Command) with the access key to activate the link. In IE 4/Windows, the Alt key is required, and the key is not case sensitive. This attribute does not work in IE 4/Mac.

 
Input Types button, checkbox, file, password, radio, reset, submit, text
 
Example
<INPUT TYPE="text" NAME="first" MAXLENGTH=15 ACCESSKEY="f"><BR>
 
Value
Single character of the document set.
 
Default None.
 
Object Model Reference
IE [window.]document.formName.inputName.accessKey
[window.]document.forms[i].elements[i].accessKey
[window.]document.all.elementID.accessKey
ALIGNNN all   IE all   HTML 3.2
ALIGN="alignmentConstant"Optional
 

Determines how the rectangle of the input image aligns within the context of the surrounding content. See the section "Alignment Constants" earlier in this chapter for a description of the possibilities defined in both Navigator and Internet Explorer for this attribute. Not all attribute values are valid in browsers prior to the Version 4 releases.

Both browsers follow the same rules on laying out content surrounding an image whose ALIGN attribute is set, but the actual results are sometimes difficult to predict when the surrounding content is complex. A thorough testing of rendering possibilities with browser windows set to various sizes prevents surprises later.

 
Input Types image
 
Example
<INPUT TYPE="image" NAME="icon" SRC="icon.gif" ALIGN="absmiddle">
 
Value
Case-insensitive constant value. All constant values are available in Navigator 4 and Internet Explorer 4.
 
Default bottom
 
Object Model Reference
IE [window.]document.formName.inputName.align
[window.]document.forms[i].elements[i].align
[window.]document.all.elementID.align
ALTNN n/a   IE 4   HTML 4
ALT="textMessage"Optional
 

If a browser is not capable of displaying graphical images (or has the feature turned off), the text assigned to the ALT attribute is supposed to display in the document where the image INPUT element's tag appears. Typically, this text provides advice on what the page visitor is missing by not being able to view the image.

 
Input Types image
 
Example
<INPUT TYPE="image" NAME="icon" SRC="sndIcon.gif" ALT="Sound Icon">
 
Value
Any quoted string of characters.
 
Default None.
 
Object Model Reference
IE [window.]document.formName.inputName.alt
[window.]document.forms[i].elements[i].alt
[window.]document.all.elementID.alt
BORDERNN 4   IE 4   HTML n/a
BORDER=pixelsOptional
 

Navigator and Internet Explorer treat images displayed by the INPUT element very much like IMG elements. As such, you can specify a border around the image. Navigator displays one by default. Because an INPUT element whose TYPE attribute is "image" acts as a submit-style button, the border is rendered in the browser's link colors. If you want a different color for a plain border, use style sheets (with the appropriate DIV or SPAN wrapper for Navigator 4). You can eliminate the colored border altogether in Navigator by setting the BORDER attribute size to zero.

 
Input Types image
 
Example
<INPUT TYPE="image" NAME="icon" SRC="sndIcon.gif" BORDER=0>
 
Value
Any integer pixel value.
 
Default 2 (Navigator 4) or 0 (Internet Explorer 4).
 
Object Model Reference
IE [window.]document.formName.inputName.border
[window.]document.forms[i].elements[i].border
[window.]document.all.elementID.border
CHECKEDNN 4   IE 3   HTML 4
CHECKEDOptional
 

A Boolean attribute that designates whether the current checkbox or radio INPUT element is turned on when the page loads. In the case of a radio button grouping, only one INPUT element should have the CHECKED attribute. Scripts can modify the internal value of this attribute after the page has loaded. When the form is submitted, an INPUT element whose CHECKED attribute is turned on sends its name/value pair as part of the form data. The name/value pair consists of values assigned to the NAME and VALUE attributes for the element. If no value is assigned to the VALUE attribute, the string value "active" is automatically assigned when the checkbox or radio button is highlighted. This is fine for checkboxes because each one should be uniquely named. However, all radio buttons in a related group must have the same name, so this default behavior doesn't provide enough information for most server-side programs to work with.

 
Input Types checkbox, radio
 
Example
<INPUT TYPE="checkbox" NAME="addToList" CHECKED>Send email updates to this 
web site.
 
Value
The presence of this attribute turns on its property.
 
Default Off.
 
Object Model Reference
NN [window.]document.formName.inputName.checked
[window.]document.forms[i].elements[i].checked
IE [window.]document.formName.inputName.checked
[window.]document.forms[i].elements[i].checked
[window.]document.all.elementID.checked
DATAFLDNN n/a   IE 4   HTML n/a
DATAFLD="columnName"Optional
 

Used with IE 4 data binding to associate a remote data source column name with parts of various INPUT elements. A DATASRC attribute must also be set for the element.

 
Input Types button, checkbox, hidden, password, radio, text
 
Example
<INPUT TYPE="text" NAME="first" DATASRC="#DBSRC3" DATAFLD="firstName">
 
Value
Case-sensitive identifier.
 
Default None.
 
Object Model Reference
IE [window.]document.formName.inputName.dataFld
[window.]document.forms[i].elements[i].dataFld
[window.]document.all.elementID.dataFld
DATASRCNN n/a   IE 4   HTML n/a
DATASRC="dataSourceName"Optional
 

Used with IE 4 data binding to specify the name of the remote ODBC data source (such as an Oracle or SQL Server database) to be associated with the element. Content from the data source is specified via the DATAFLD attribute.

 
Input Types button, checkbox, hidden, password, radio, text
 
Example
<INPUT TYPE="text" NAME="first" DATASRC="#DBSRC3" DATAFLD="firstName">
 
Value
Case-sensitive identifier.
 
Default None.
 
Object Model Reference
IE [window.]document.formName.inputName.dataSrc
[window.]document.forms[i].elements[i].dataSrc
[window.]document.all.elementID.dataSrc
DISABLEDNN n/a   IE 4   HTML 4
DISABLEDOptional
 

A disabled INPUT element appears grayed out on the screen and cannot be activated by the user. In Windows, a disabled form control cannot receive focus and does not become active within the tabbing order rotation. HTML 4.0 also specifies that the name/value pair of a disabled INPUT element should not be sent when the form is submitted. INPUT elements that normally perform submissions do not submit their form when disabled.

The DISABLED attribute is a Boolean type, which means that its presence in the attribute sets its value to true. Its value can also be adjusted after the fact by scripting (see the button object in ).

 
Input Types All.
 
Example
<BUTTON TYPE="submit" DISABLED>Ready to Submit </BUTTON>
 
Value
The presence of the attribute disables the element.
 
Default false
 
Object Model Reference
IE [window.]document.formName.inputName.disabled
[window.]document.forms[i].elements[i].disabled
[window.]document.all.elementID.disabled
IDNN n/a   IE 4   HTML 4
ID="elementIdentifier"Optional
 

A unique identifier that distinguishes this element from all the rest in the document. Can be used to associate a single element with a style rule naming this attribute value as an ID selector. Do not confuse the ID attribute with the NAME attribute, whose value is submitted as part of a name/value pair with the form.

 
Input Types All.
 
Example
<INPUT TYPE="button" ID="next" VALUE=">>Next>>" onClick="goNext(3)">
 
Value
Case-sensitive identifier.
 
Default None.
 
Object Model Reference
IE [window.]document.formName.inputName.id
[window.]document.forms[i].elements[i].id
[window.]document.all.elementID.id
MAXLENGTHNN all   IE all   HTML all
MAXLENGTH="characterCount"Optional
 

Defines the maximum number of characters that may be typed into a text field INPUT element. In practice, browsers beep or otherwise alert users when a typed character would exceed the MAXLENGTH value. There is no innate correlation between the MAXLENGTH and SIZE attributes. If the MAXLENGTH allows for more characters than fit within the specified width of the element, the browser provides horizontal scrolling (albeit awkward for many users) to allow entry and editing of the field.

 
Input Types password, text