我有一个 Javascript 文件,用于检查表单的输入。但是,当我取消注释注释行时,javascript 文件无法正常运行,即使某些字段为空白,也会提交表单。事实上,Javascript 文件甚至没有进入第二个警报函数。到底是怎么回事?
function checkLogin()
{
alert("HERE");
//document.getElementById("errors").style.display = "none";
var form = document.getElementById("form1");
var problems = false;
document.getElementById("errorJS").style.display = "none";
document.getElementById("errorJS").innerHTML = "";
alert("test");
if(form.email.value.length < 1)
{
document.getElementById("errorJS").innerHTML += "Please enter your email address. <br />";
problems = true;
document.getElementById("errorJS").style.display = "block";
}
if(form.pword.value.length < 1)
{
document.getElementById("errorJS").innerHTML += "Please enter your password.";
problems = true;
document.getElementById("errorJS").style.display = "block";
}
alert(!(problems));
return !(problems);
}
就是这样,该行返回null。谢谢你的回答。