Javascript examples for DOM HTML Element:Input Password
The name property sets or gets the name attribute of a password field.
Set the name property with the following Values
Value | Description |
---|---|
name | Sets the name of the password field |
A String, representing the name of the password field
The following code shows how to get the name of a password field:
<!DOCTYPE html> <html> <body> <form> Password: <input type="password" id="myPsw" name="pw"> </form>/*w ww.ja v a2s. co m*/ <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myPsw").name; console.log("The name of the password field is: " + x); } function change() { var x = document.getElementById("myPsw").name = "newPasswordName"; console.log("The name was changed to: " + x); } </script> </body> </html>