input (type="password") | NN 2 IE 3 DOM 1 | |||||||||||||||||||||||||||||||
The password object is a form control generated with an input element that has a type attribute set to "password". This object is similar to the text input object, except that the characters typed into the text box by the user are converted to asterisk or bullet symbols for privacy. |
||||||||||||||||||||||||||||||||
HTML Equivalent | ||||||||||||||||||||||||||||||||
<input type="password"> |
||||||||||||||||||||||||||||||||
Object Model Reference | ||||||||||||||||||||||||||||||||
[window.]document.formName.elementName [window.]document.forms[i].elements[i] [window.]document.getElementById("elementID") |
||||||||||||||||||||||||||||||||
Object-Specific Properties | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Object-Specific Methods | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Object-Specific Event Handler Properties | ||||||||||||||||||||||||||||||||
|
dataFld | NN n/a IE 4 DOM n/a |
Read/Write | |
Used with IE data binding to associate a remote data source column name to a password object's value property. A datasrc attribute must also be set for the element. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac. |
|
Example | |
document.myForm.myPassword.dataFld = "userWurd"; |
|
Value | |
Case-sensitive identifier of the data source column. |
|
Default | |
None. |
dataSrc | NN n/a IE 4 DOM n/a |
Read/Write | |
Used with IE data binding to specify the ID of the page's object element that loads the data source object for remote data access. Content from the data source is specified via the datafld attribute. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac. |
|
Example | |
document.myForm.myPassword.dataSrc = "#DBSRC3"; |
|
Value | |
Case-sensitive identifier of the data source. |
|
Default | |
None. |
defaultValue | NN 2 IE 3 DOM 1 |
Read-only | |
Indicates the default text for the password input element, as established by the value attribute. |
|
Example | |
var pwObj = document.forms[0].myPassword; if (pwObj.value != pwObj.defaultValue ) { // process user-entered password } |
|
Value | |
String value. |
|
Default | |
None. |
form | NN 2 IE 3 DOM 1 |
Read-only | |
Returns a reference to the form element that contains the current element (if any). When processing an event from this element, the event handler function automatically has access to the input element (as the event object's target or srcElement property). By reading the form property, the script can easily access other controls within the same form. |
|
Example | |
var theForm = evt.srcElement.form; |
|
Value | |
form element object reference. |
|
Default | |
None. |
maxLength | NN 6 IE 4 DOM 1 |
Read/Write | |
Specifies the maximum number of characters that may be typed into a password 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 properties. 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. |
|
Example | |
document.entryForm.myPassword.maxLength = 35; |
|
Value | |
Integer value. |
|
Default | |
Unlimited. |
name | NN 2 IE 3 DOM 1 |
Read/Write | |
This is the identifier associated with the form control. The value of this property is submitted as one-half of the name/value pair when the form is submitted to the server. Names are hidden from user view, since control labels are assigned via other means, depending on the control type. Form control names may also be used by script references to the objects. Despite the modern standards' preference for the id attribute, many browsers still require that a form control be assigned a name attribute to allow the control's value to be submitted. |
|
Example | |
document.orderForm.myPassword.name = "pw"; |
|
Value | |
Case-sensitive string identifier that follows the rules of identifier naming: it may contain no whitespace, cannot begin with a numeral, and should avoid punctuation except for the underscore character. |
|
Default | |
None. |
readOnly | NN 6 IE 4 DOM 1 |
Read-only | |
Specifies whether the form element can be edited on the page by the user. A form control whose readOnly property is true may still be modified by scripts, even though the user may not alter the content. |
|
Example | |
if (document.forms[0].myPassword.readOnly ) { ... }; |
|
Value | |
Boolean value: true | false. |
|
Default | |
false |
selectionEnd, selectionStart | NN 6 IE n/a DOM n/a |
Read/Write | |
The selectionEnd and selectionStart properties are convenience properties introduced with Netscape 6. They allow scripts to get and set the end positions of a text selection within a text-oriented input element. Values are zero-based integer counters of positions between characters in the text entered into the field. When both properties have the same value, the visual result is the same as a text insertion pointer. For example, to place the cursor at the end of a text box, set the two values to the element's text length (see the textLength property). The equivalent IE functionality requires creating an IE text range in the element, adjusting the range's endpoints, and selecting the range (see the TextRange object). |
|
Example | |
var elem = document.forms[0].myPassword; elem.selectionEnd = elem.textLength; elem.selectionStart = elem.textLength; |
|
Value | |
Positive integer. |
|
Default | |
None. |
size | NN 6 IE 4 DOM 1 |
Read/Write | |
Roughly speaking, the width in characters that the input box should be sized to accommodate. In practice, the browser does not always accurately predict the proper width even when all characters are the same, as they are in the password object. See details in the size attribute discussion for the input element in Chapter 8. There is no interaction between the size and maxLength properties for this object. |
|
Example | |
document.forms[0].myPassword.size = 12; |
|
Value | |
Integer. |
|
Default | |
20 |
textLength | NN 6 IE n/a DOM n/a |
Read-only | |
The textLength convenience property (introduced with Netscape 6) returns the length of text entered into the text field. The value is same as the length of the value property. |
|
Example | |
var elem = document.forms[0].myPassword; elem.selectionEnd = elem.textLength; elem.selectionStart = elem.textLength; |
|
Value | |
Positive integer. |
|
Default | |
None. |
type | NN 3 IE 4 DOM 1 |
Read-only | |
Returns the type of form control element. The value is returned in all lowercase letters. It may be necessary to cycle through all form elements in search of specific types to do some processing on (e.g., emptying all form controls of type "text" while leaving other controls untouched). |
|
Example | |
if (document.forms[0].elements[3].type == "password") { // process password input type here } |
|
Value | |
Any of the following constants (as a string): button | checkbox | file | hidden | image | password | radio | reset | select-multiple | select-one | submit | text | textarea. |
|
Default | |
password |
value | NN 2 IE 3 DOM 1 |
Read/Write | |
Indicates the current value associated with the form control that is submitted with the name/value pair for the element. All values are strings. Browsers return the actual characters typed by the user (except in Navigator 2), so you can retrieve an entered password for further processing before submission (or perhaps for storage in the cookie). |
|
Example | |
document.forms[0].myPassword.value = "franken"; |
|
Value | |
String. |
|
Default | |
None. |
createTextRange( ) | NN n/a IE 4(Win) DOM n/a |
Creates a TextRange object containing the field's value text. See the TextRange object for details. |
|
Parameters | |
None. |
|
Returned Value | |
TextRange object. |
handleEvent[ ] | NN |4| IE n/a DOM n/a |
handleEvent(event) | |
Instructs the object to accept and process the event whose specifications are passed as the parameter to the method. The object must have an event handler for the event type to process the event. Navigator 4 only |
|
Parameters | |
|
|
Returned Value | |
None. |
select( ) | NN 2 IE 3 DOM 1 |
Selects all the text displayed in the form element. Usually requires that the element have focus prior to invoking this method. |
|
Parameters | |
None. |
|
Returned Value | |
None. |