我有以下的HTML表單之前GET請求發送密碼匹配使用JS完成,但JS不工作Java腳本不執行
<html>
<title>Login System</title>
<head>
<script type="text/javascript">
function match()
{
var s1=document.getElementById('t4').value;
var s2=document.getElementById('t5').value;
if (s1 == s2)
{
alert('yep');
}
else
{
alert('Passwords Does not Match');
}
}
</script>
</head>
<style type="text/css">
div.ex {
width:220px;
padding:10px;
border:5px solid gray;
margin:10px;
}
</style>
<body>
<div class="ex">
<strong>User Login</strong>
<form name=f1 method=get action="http://localhost:8080/login">
User         <input type=text name=t1><br>
Password <input type=password name=t2><br>
<input type=submit name=sub value="Login">
</form>
</div>
<div class="ex">
<strong>User Registration</strong>
<form name=f2 method=get action="http://localhost:8080/login">
User Name      <input type=text name=t3><br>
Password <input type=password name=t4><br>
Password <input type=password name=t5><br>
<input type=submit name=sub value="reg" onclick='match();'>
</form>
</div>
</body>
</html>
它可能是最好的'==='來比較你的密碼。你還有什麼錯誤? – cclerville 2013-02-25 05:04:46
如果's1!= s2',您需要防止事件進一步處理。 – Passerby 2013-02-25 05:05:56
@cclerville沒有錯誤,servlet在沒有密碼檢查的情況下執行,並且根本沒有任何提示框 – techno 2013-02-25 05:06:04