input type="password" Element


 

Module

The input type="password" element is an inline element declared by the XHTML 1.1 Forms Module

Elements in the Forms Module are:
form | label | textarea | select | optgroup | option | button | fieldset | legend |
input type="button" | input type="checkbox" | input type="file" | input type="hidden" | input type="image" | input type="password" | input type="radio" | input type="reset" | input type="submit" | input type="text"

Description

The input type="password" element is used within a form to provide a single-line text box where the text is obscured, character by character, as it is entered. This prevents onlookers from viewing the text within the box: usually each character is represented on-screen as an asterisk. As the element's name suggests, input type="password" fields are typically used for password entry.

Important: When the form containing an input type="password" element is submitted, the password is transmitted (as is all form data) in clear text. This means that a password box must be used in conjunction with a suitably secure and encrypted connection if the password is to be transmitted safely.

The width of the password box may be specified using the size attribute.

The maxlength attribute may be used to specify the maximum number of characters which the user is allowed to enter. The user agent should prevent the user from entering more characters than this maximum number. Note, however, that processing code should not assume that it will never receive a value longer than this: quite apart from anything else, it is far from difficult to submit arbitrary input data to your processor without using a conventional browser.

The content of the value attribute (if present) is placed in the password box (in a obscured fashion, commonly a series of asterisks) when the form is first rendered. The user may then edit the text (provided the element is not disabled or readonly) and the final edited text is sent to the processing URI as the value in a name=value pair.

Here is an example using the input type="password" element:

<label for="pword">Password:</label>
<input type="password" id="pword" name="pword" size="20" maxlength="16" />

This renders as:

See also the input type="text" element for the entry of short lengths of normal, unobscured, text.

#REQUIRED Attributes

Although the type attribute is not #REQUIRED on the input element, its default value is "text" and so must be present on input type="password".


Specific Attributes

Specific attributes of the input type="password" element are listed below:

From the Forms Module - the Element's own Module

accesskey [ type Character ]
Key to be pressed which allows focus to be directed immediately to this input element to allow text input
disabled [ type Boolean ]
If this attribute is present, the password input field is initially disabled - no data is sent to the processing URI for disabled elements when the form is submitted. The user cannot interact with a disabled control.
maxlength [ type Number ]
The maximum number of characters accepted by the password control
name [ type CDATA ]
This is the name sent to the processing URI for the password input field when the form is submitted (if the name attribute is not present, the value of the password field will not be sent). The value sent (in a name=value pair) is the text in the password field at the time of submission.

Important Note: Although the password is hidden from onlookers by having the characters appear as (typically) only a string of asterisks in the input field, the value itself is sent in clear text to the processing URI. A suitably secure and encrypted connection should be used to protect sensitive data.

Note: Although technically optional, a note in the *Forms Module DTD says that the name attribute is required on all input elements except "submit" and "reset"

readonly [ type Boolean ]
If this attribute is present, the password input field may not (initially) be modified by the user. Data may still be sent to the processing URI for readonly fields.
size [ type Number ]
Initial display width of the password input field in characters (based on an average character width)
tabindex [ type Number ]
An integer between 0 and 32767 specifying the position of the password input field in the tabbing order of the document
value [ type CDATA ]
The initial value to be entered in the password input field when the form is first rendered - the field is returned to this value if the form is reset

From the Intrinsic Events Module

onblur [ type Script ]
Script to be executed when the element loses focus
onchange [ type Script ]
Script to be executed if the text within the password input field has been changed (it is triggered only when the element loses focus and its content has changed since last gaining focus)
onfocus [ type Script ]
Script to be executed when the element receives focus
onselect [ type Script ]
Script to be executed when some text within the password input field is highlighted

Common Attributes

Common attributes of the input type="password" element are listed below:

From the Core Attribute Collection

class [ type NMTOKENS ]
One or more space separated classes
id [ type ID ]
A unique identifier for the element
style [ type CDATA ], from the Style Attribute Module (deprecated)
Element-specific styles
title [ type Text ]
Descriptive title for the element (in some user agents this may appear as a "tooltip" when the mouse hovers over the element)
xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]
XML namespace

From the I18N Attribute Collection

dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Module
Left-to-right or right-to-left directionality
xml:lang [ type LanguageCode ]
A language code for the element

From the Events Attribute Collection

All attributes in the Events Attribute Collection are supported:
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup


Content Model

The Content Model for the input type="password" element is:

EMPTY

See Content Model & Nesting for information about Content Model syntax and Nesting Groups.

Valid children of input type="password"

This element is empty and may have no children.

Valid parents of input type="password"


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 01 Oct 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Element Index (XHTML 1.1) > input Elements > input type="password"