Thuộc tính value của <input type="password"> lấy/đặt giá trị mặc định hoặc giá trị người dùng nhập (dạng text thuần, không mã hóa).
Cú pháp
passwordObject.value = "text"
Ví dụ
Lấy giá trị nhập vào password field:
<!DOCTYPE html> <html> <body>
<h1>Input password value property</h1>
PASSWORD: <input type="password" id="PASS1">
<p>Nhấn nút để lấy giá trị nhập</p>
<button onclick="getValue()">LẤY GIÁ TRỊ</button>
<p id="Sample"></p>
<script>
function getValue() {
var t = document.getElementById("PASS1").value;
document.getElementById("Sample").innerHTML = "Giá trị nhập: " + t;
}
</script> </body> </html>
Kết quả
Trước khi nhập:

Sau khi nhập "123456" và nhấn nút:
