Password formProperty

Password 对象参考手册Password Object

Definition and Usage

The form property returns a reference to the form that contains the password field.

This property returns a form object.

Syntax

passwordObject.form


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the form property


Example

Example

The following example gets the id of the form that the password field belongs to:

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

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

</body>
</html> 

Try it Yourself »


Password 对象参考手册Password Object Other Extensions