我对JavaScript有点新鲜。我试图为我的网站编写一个函数来检查用户输入的密码是否与预定的密码(“abc”)匹配。密码以表格形式输入。JavaScript匹配密码
这是我到目前为止,虽然它似乎并没有工作。
function done() {
var the_pass="abc";
document.getElementById("popup").style.display = "none";
var password = document.getElementById("pass").value;
if(password.value.match(the_pass))
{
alert('Correct, try another...')
return true;
}
else
{
alert('Wrong...!')
return false;
}
不要忘记检查错误控制台 –