Created
March 21, 2025 18:45
-
-
Save EncodeTheCode/7be8d43a62b2a668a5bf9163cce115c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Password Reader</title> | |
<script> | |
// Extend HTMLInputElement prototype | |
HTMLInputElement.prototype.getPasswordValue = function() { | |
if (this.type === "password") { | |
return String(this.value); // Ensure the return value is a string | |
} else { | |
console.warn("This function is intended for password fields only."); | |
return ""; | |
} | |
}; | |
function readPassword() { | |
let passwordField = document.getElementById("password"); | |
alert("Password value: " + passwordField.getPasswordValue()); | |
} | |
</script> | |
</head> | |
<body> | |
<label for="password">Enter Password:</label> | |
<input type="password" id="password"> | |
<button onclick="readPassword()">Read Password</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment