无论我做什么,我都无法建立一个工作机制来检查登录数据是否良好,因为应该捕获的元素通过数据不会捕获任何内容。我正在调试 这是我的表格:
<form onsubmit= "return validate()" method="POST">
Prvo polje:<input type="text" id='prvopolje'/>
Drugo polje:<input type="text" id='drugopolje'/>
Pass:<input type="password" id='passpolje'/>
<input type="submit" value="submit"/>
这是我的密码验证功能:
function validate() {
var polje1 = document.getElementById("prvopolje");
var polje2 = document.getElementById("drugopolje");
var passpolje = document.getElementById("passpolje");
//these vars don't catch anything
function validatepass() {
if(passpolje.innerHTML.includes("#") ||
passpolje.innerHTML.includes("*") ||
passpolje.innerHTML.includes(" ") ||
passpolje.innerHTML.includes("!") ||
passpolje.innerHTML.includes("$") ||
passpolje.innerHTML.includes("@") ||
passpolje.innerHTML.includes(".") ||
passpolje.innerHTML.includes(",") ||
passpolje.innerHTML.includes("&") ||
passpolje.innerHTML.includes("%") ||
passpolje.innerHTML.includes(";"))
{
console.log("Successful pass validation!");
return true;
}
else
{
console.log("Not strong enough, add symbols #,*, ,!,$,@,.,,,&,%,;");
return false;
}
}
if(polje1.innerHTML !="" || polje2.innerHTML!="" || validatepass())
{
return true;
}
else return false;
}
奇怪的是,这里的一些数据实际上可以在调试模式下看到 enter image description here