Input Password value Property

❮ Input Password Object

Example

Get the value of the value attribute of a password field:

var x = document.getElementById("myPsw").value;
Try it Yourself »

Description

The value property sets or returns the value of the value attribute of a password field.

The value attribute contains the default value OR the value a user types in (or a value set by a script).


Browser Support

Property
value Yes 10.0 Yes Yes Yes

Syntax

Return the value property:

passwordObject.value

Set the value property:

passwordObject.value = text

Property Values

Value Description
text Specifies the value of the password field


Technical Details

Return Value: A String, representing the password of the password field

More Examples

Example

Change the value of the password field:

document.getElementById("myPsw").value = "NewPassword123";
Try it Yourself »

Example

An example that shows the difference between the defaultValue and value property:

var x = document.getElementById("myPsw");
var defaultVal = x.defaultValue;
var currentVal = x.value;
Try it Yourself »

Related Pages

HTML reference: HTML <input> value attribute


❮ Input Password Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.