HTMLInputElement |
an input element in an HTML form |
Availability
DOM Level 1 HTML
Inherits from/Overrides
Node Element HTMLElement HTMLInputElement
Properties
- String accept
-
A
comma-separated list of MIME types that specify the types of files
that may be uploaded when this is a FileUpload element. Mirrors the
accept attribute.
- String accessKey
-
The
keyboard shortcut (which must be a single character) that a browser
may use to transfer keyboard focus to this input element. Mirrors the
accesskey attribute.
- deprecated String align
-
The vertical
alignment of this element with respect to the surrounding text, or
the left or right float for the element. Mirrors the
align attribute.
- String alt
-
Alternate text
to be displayed by browsers that cannot render this input element.
Particularly useful when type is
image. Mirrors the alt
attribute.
- boolean checked
-
For Radio
and Checkbox input elements, specifies whether the element is
"checked" or not. Setting this property changes the
visual appearance of the input element. Mirrors the
checked attribute.
- boolean defaultChecked
-
For
Radio and Checkbox elements, holds the initial value of the
checked attribute as it appears in the document
source. When the form is reset, the checked
property is restored to the value of this property. Changing the
value of this property changes the value of the
checked property and the current checked state of
the element.
- String defaultValue
-
For
Text, Password, and FileUpload elements, holds the initial value
displayed by the element. When the form is reset, the element is
restored to this value. Changing the value of this property also
changes the value property and the currently
displayed value.
- boolean disabled
-
If
true, the input element is disabled and is
unavailable for user input. Mirrors the disabled
attribute.
- readonly HTMLFormElement form
-
The
HTMLFormElement object representing the
<form> element that contains this input
element, or null if the input element is not
within a form.
- long maxLength
-
For Text
or Password elements, specifies the maximum number of characters that
the user will be allowed to enter. Note that this is not the same as
the size property. Mirrors the
maxlength attribute.
- String name
-
The name of
the input element, as specified by the name
attribute.
- boolean readOnly
-
If
true, and this is a Text or Password element, the
user is not allowed to enter text into the element. Mirrors the
readonly attribute.
- String size
-
For Text and
Password elements, specifies the width of the element in characters.
Mirrors the size attribute. See also
maxLength.
- String src
-
For input
elements with a type of image,
specifies the URL of the image to be displayed. Mirrors the
src attribute.
- long tabIndex
-
The
position of this input element in the tabbing order. Mirrors the
tabindex attribute.
- String type
-
The type of
the input element. The various types and their meanings are listed in
the table in the "Description" section. Mirrors the
type attribute.
- String useMap
-
For elements
with a type of image, specifies
the name of a <map> element that provides a
client-side image map for the element.
- String value
-
The value
that is passed to the server-side script when the form is submitted.
For Text, Password, and FileUpload elements, this property is the
text contained by the input element. For Button, Submit, and Reset
elements, this is the text that appears in the button. For security
reasons, the value property of FileUpload elements
may be read-only. Similarly, the value returned by this property for
Password elements may not contain the user's actual input.
Methods
- blur( )
-
Takes keyboard focus away from the element.
- click( )
-
If this input element is a Button, a Checkbox, or a Radio, Submit, or
Reset button, this method simulates a mouse-click on the element.
- focus( )
-
Transfers keyboard focus to this input element.
- select( )
-
If this input element is a Text, Password, or FileUpload element,
this method selects the text displayed by the element. In many
browsers, this means that when the user next enters a character, the
selected text will be deleted and replaced with the newly typed
character.
Description
This interface represents an <input> element
that defines an HTML input element (typically in an HTML form). An
HTMLInputElement can represent various types of input elements,
depending on the value of its type property. The
allowed values for this property and their meanings are shown in the
following table.
button
|
Push button
|
checkbox
|
Checkbox element
|
file
|
FileUpload element
|
hidden
|
Hidden element
|
image
|
Graphical Submit button
|
password
|
Masked-text entry field for passwords
|
radio
|
Mutually exclusive Radio button
|
reset
|
Reset button
|
text (default value)
|
Single-line text entry field
|
submit
|
Submit button
|
See Chapter 15 for more information about HTML
forms and form elements. Note also that each distinct type of form
input element has its own reference page in the client-side reference
section of this book.
See Also
HTMLFormElement, HTMLOptionElement, HTMLSelectElement,
HTMLTextAreaElement; Chapter 15; the Input object
in the client-side reference section, and also its subclasses
(Button, Checkbox, FileUpload, Hidden, Password, Radio, Reset,
Submit, and Text)
|