Password object (Object/DOM)

A text field in a form that echoes bullets instead of the typed character. Behaves as if it were a text cell but you cannot see what was typed.

Availability:

DOM level - 1
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
Inherits from:Input object
JavaScript syntax:-myPassword = myDocument.aFormName.anElementName
-myPassword = myDocument.aFormName.elements[anItemIndex]
IEmyPassword = myDocument.all.anElementID
IEmyPassword = myDocument.all.tags("INPUT")[anIndex]
IEmyPassword = myDocument.all[aName]
-myPassword = myDocument.forms[aFormIndex].anElementName
-myPassword = myDocument.forms[aFormIndex].elements[anItemIndex]
-myPassword = myDocument.getElementByID(anElementID)
-myPassword = myDocument.getElementsByName(aName)[anIndex]
-myPassword = myDocument.getElementsByTagName("INPUT")[anIndex]
HTML syntax:<INPUT TYPE="password">
Argument list:anIndexA valid reference to an item in the collection
aNameThe name attribute of an element
anElementIDThe ID attribute of an element
anItemIndexA valid reference to an item in the collection
aFormIndexA reference to a particular form in the forms collection
Object properties:maxLength, readOnly, size, type, value
Object methods:handleEvent(), select()
Event handlers:onAfterUpdate, onBeforeUpdate, onBlur, onChange, onFilterChange, onFocus, onHelp, onKeyDown, onKeyPress, onKeyUp, onMouseDown, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onResize, onRowEnter, onRowExit, onSelect, onSelectStart

Many properties, methods and event handlers are inherited from the Input object class. Refer to topics grouped with the "Input" prefix for details of common functionality across all sub-classes of the Input object super-class.

Event handling support via properties containing function objects was added to Password objects at version 1.1 of JavaScript.

Some implementations will not allow JavaScript to read the password string that the user has entered. This is good. You might imagine otherwise on the grounds that you'd expect then that JavaScript then won't be able to validate the password. If you think about this for a minute you'll realize that View Source in a web browser exposes your entire security checking regime. Its actually quite sensible to disallow JavaScript from inspecting the password field. But then, all the user has to do is run different browser - one that does access the contents of the password field.

Realistically the validation of the password can only be done back at the server anyway and other than some simple range checking in the client end access to password values from JavaScript is of doubtful use.

See also:Element object, Form.elements[], FormElement object, Input object, Input.accessKey, onBlur, onChange, onFocus, Password.handleEvent()

PropertyJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
maxLength n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
readOnly n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aReadOnly.
size n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aWarning
type1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.0 n/a n/a1 1 n/a n/aReadOnly.
value1.0 1.01.0 1.02.0 2.03.02 3.023.0 3.0 n/a n/a1 1 n/a n/a-

MethodJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
handleEvent()1.2 1.2 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a n/a-
select()1.0 1.01.0 1.02.0 2.03.02 3.023.0 3.0 n/a n/a1 1 n/a n/a-

Event nameJavaScriptJScriptNIEOperaNESECMADOMCSSHTMLNotes
onAfterUpdate n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
onBeforeUpdate n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
onBlur1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.0 n/a n/a n/a n/a n/aWarning
onChange1.0 1.03.0 3.02.0 2.04.0 4.03.0 3.0 n/a n/a n/a n/a n/a-
onFilterChange n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
onFocus1.0 1.03.0 3.02.0 2.04.0 4.03.0 3.0 n/a n/a n/a n/a n/aWarning
onHelp n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/aWarning
onKeyDown1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onKeyPress1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onKeyUp1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onMouseDown1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onMouseMove1.2 1.23.0 3.04.0 4.04.0 4.0 n/a n/a n/a n/a n/a4.0 4.0Warning
onMouseOut1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onMouseOver1.0 1.01.0 1.02.0 2.03.0 3.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onMouseUp1.2 1.23.0 3.04.0 4.04.0 4.03.0 3.0 n/a n/a n/a n/a4.0 4.0Warning
onResize1.2 1.23.0 3.04.0 4.04.0 4.0 n/a n/a n/a n/a n/a n/aWarning
onRowEnter n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
onRowExit n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-
onSelect1.0 1.03.0 3.02.0 2.04.0 4.03.0 3.0 n/a n/a n/a n/a n/a-
onSelectStart n/a3.0 3.0 n/a4.0 4.0 n/a n/a n/a n/a n/a n/a-

Inheritance chain:

Element object, Input object, Node object

Cross-references:

O'Reilly JavaScript Definitive Guide - page - 645