<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