
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Password name Property
The HTML DOM Input Password name property is used for setting or returning the name attribute of an input password field. The name attribute helps in identifying the form data after it has been submitted to the server. JavaScript can also use the name attribute to refer form elements to manipulate later on.
Syntax
Following is the syntax for −
Setting the name property −
passwordObject.name = name
Here, name is for specifying the password field name.
Example
Let us look at an example for the password name property −
<!DOCTYPE html> <html> <body> <h1>Input Password name Property</h1> Password: <input type="password" id="PASS" name="passW"> <p>Change the name of the password field by clicking the below button</p> <button onclick="changeName()">CHANGE NAME</button> <p id="Sample"></p> <script> function changeName() { document.getElementById("PASS").name ="NEW_PASS" ; document.getElementById("Sample").innerHTML = "Password field name is now NEW_PASS"; } </script> </body> </html>
Output
This will produce the following output −
On clicking the CHANGE NAME button −
In the above example −
We have first created an input password field with id “PASS” and having its name attribute value set to “passW” −
Password: <input type="password" id="PASS" maxLength=”5”>
We have then created a button CHANGE NAME that will execute the changeName() when clicked by the user −
<button type="button" onclick="changeName()">CHANGE NAME</button>
The changeName() method uses the getElementById() method to get the input field with type password and sets it name property to “NEW_PASS”. We then show this change by displaying a message in the paragraph with id “Sample” using its innerHTML property −
function changeName() { document.getElementById("PASS").name ="NEW_PASS" ; document.getElementById("Sample").innerHTML = "Password field name is now NEW_PASS"; }
- Related Articles
- HTML DOM Input Password value property
- HTML DOM Input Password pattern property
- HTML DOM Input Password placeholder property
- HTML DOM Input Password readOnly property
- HTML DOM Input Password required property
- HTML DOM Input Password size property
- HTML DOM Input Password type property
- HTML DOM Input Password autofocus Property
- HTML DOM Input Password defaultValue Property
- HTML DOM Input Password disabled Property
- HTML DOM Input Password form Property
- HTML DOM Input Password maxLength Property
- HTML DOM Input Button name Property
- HTML DOM Input FileUpload name Property
- HTML DOM Input Hidden name Property
