0
我需要你的幫助。我有一個非常簡單的問題,我無法弄清楚。它很難解釋,但我對一條線有評論,我希望你能理解它。這是我的代碼。對於長篇帖子感到抱歉,但我似乎無法擺脫這個漏洞。document.getElementById(「ID」)。value not working
function CheckLength()
{
var stringpassword = document.getElementById('Pass').value;
alert(document.getElementById('Pass').value); --> this part is only printing a blank.
/*
if(document.getElementById("Pass").value.length > 8)
{
return true;
}
else
{
alert(document.getElementById("Pass").value.length);
return false;
}
*/
}
function Check(a)
{
switch(a)
{
case 1 :
var first = document.getElementById("Uname").value.toUpperCase().indexOf(document.getElementById("Fname").value.toUpperCase());
var last = document.getElementById("Uname").value.toUpperCase().indexOf(document.getElementById("Lname").value.toUpperCase());
if(first !=-1 || last != -1)
{
alert("huy mali ang username. bawal yan pre");
document.getElementById("Uname").value = "";
}
break;
case 2 :
var gate = 0;
var first = document.getElementById("Pass").value.toUpperCase().indexOf(document.getElementById("Fname").value.toUpperCase());
var last = document.getElementById("Pass").value.toUpperCase().indexOf(document.getElementById("Lname").value.toUpperCase());
if(first !=-1 || last != -1)
{
alert("mali dahil sa name");
gate++;
}
if(!CorrectPassword())
{
gate++;
}
if(!CheckLength())
{
gate++;
}
if(gate != 0)
{
alert("Please follow password policy");
document.getElementById("Pass").value="";
}
break;
case 3:
if(document.getElementById("Pass").value != document.getElementById("Rpass").value)
{
document.getElementById("Rpass").value = "";
}
break;
}
}
在身體某處:
<input type="Password" placeholder="Password" value="" id="Pass" onblur="Check(2)"/>
但是當我嘗試它。在密碼字段上輸入密碼後,點擊其他一些。警報框只會返回一個空白警報框。即使簡單的賦值語句不起作用?原諒我的壞英語