Easy Tutorial
❮ Prop Element Lastelementchild Prop Html Accesskey ❯

Password name Attribute


Definition and Usage

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

The name attribute is used to send data to the server after form submission or to reference form data in JavaScript.

Note: Only the name attribute of form elements is used to pass data values after form submission.

Syntax

Set the name attribute:

Return the name attribute:


Browser Support

All major browsers support the name attribute.


Example

The following example retrieves the name of the password field:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</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()">Display Name</button>

</body>
</html>

❮ Prop Element Lastelementchild Prop Html Accesskey ❯