Password nameProperty

Password 对象参考手册Password Object

Definition and Usage

The name property sets or returns the name of the password field.

The name property is used to transfer data to the server after form submission, or to reference form data in JavaScript.

Note:After form submission, only the name attribute of the form element transfers the data value.

Syntax

Set the name property:

passwordObject.name="name"

Return the name property:

passwordObject.name


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the name property


Example

Example

The following example gets the name of the password field:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("pwd").name;
    alert(x);
}
</script>
</head>
<body>

<form>
Password: <input type="password" id="pwd" name="password">
</form>
<button type="button" onclick="displayResult()">Show Name</button>

</body>
</html>

Try it yourself »


Password 对象参考手册Password Object Other Extensions