<input type="password" placeholder="Password name" id="box2">
var pass=document.getElementById('box2').value;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("formchek").innerHTML = xhttp.responseText;
} };
xhttp.open("POST", "chek.php?msg="+pass, true);
xhttp.send();
}
這裏,當我使用輸入類型=「密碼」我沒有得到密碼的值存儲在ID box2的文本框中使用上面的代碼,但使用輸入類型=「文本「給我的價值。所以我想如何使用輸入類型=」密碼「來獲取值。當想要在JavaScript變量中存儲密碼類型
別喊。我們可以聽到你。 – Tushar
'.value'在文本和密碼輸入方面的工作方式完全相同。 – Quentin
也許這不起作用,因爲你的代碼是在你的輸入後立即在這個例子中?用戶不能填寫任何內容。嘗試'onchange'或'onsubmit' ... – somethinghere