<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page import = "java.util.*" %>
<%@ page import = "util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>登錄頁面</title>
<script language = "JavaScript" type = "text/javascript">
// (function(){
// var sub = document.getElementById("sub");
//初始化移入移出事件
//if(sub.addEventListener){
//sub.addEventListener("click", check);
//}else if(sub.attachEvent){
// sub.attachEvent("onClick", check);
//}
//})();
function check(f){
var pwd = f.upass.value;
var acpwd = f.acupass.value;
var vc = f.yanzheng.value;
var vcode = f.img.value;
boolean ret = true;
if(pwd != acpwd){
alert("兩次密碼不相同!!!");
ret = false;
window.location.reload;
}else if(vcode != vc)){
alert("驗證碼不對!!!");
ret = false;
window.location.reload;
}else{
document.forms[0].submit();
}
return ret;
}
</script>
<body>
<from action = "LoginServ" method = "post" name = "loginform" onSubmit = "return check(this)">
用戶名: <input type="text" name="id"/><br/>
密 碼:
<input type="password" name="upass" id="upass"/><br/>
確認密碼:<input type="password" name="acupass" id="acupass"/><br/>
驗證碼:
<input type="text" name="excode" id="yanzheng"/>
<%
Tools t = new Tools();
String vcode = t.ExperimentCode();
%>
<img src="/WebBook/images/vcode.png" id = "img"/><br/>
<input type="radio" name="identity" value="con" checked="checked" />買家
<input type="radio" name="identity" value="sel" />賣家
<input id = "sub" type="submit" value="登錄"/>
<input type="reset" value="清空"/>
</from>
</body>
</html>
語法都錯了,js和java混用了
function check(f) {
var pwd = f.upass.value;
var acpwd = f.acupass.value;
var vc = f.yanzheng.value;
var vcode = f.img.value;
var ret = true;///js沒有boolean關鍵字
if (pwd != acpwd) {
alert("兩次密碼不相同!!!");
ret = false;
window.location.reload;
} else if (vcode != vc)/*)這裡多了個反括號*/ {
alert("驗證碼不對!!!");
ret = false;
window.location.reload;
} else {
document.forms[0].submit();
}
return ret;
}