日期:2014-05-16  浏览次数:20343 次

麻烦大家帮我看一下这段代码,为什么alert不好用呢??!! 我想要做两次密码不同就警示和不输入完整信息就警示的操作!
<%@ page language="java" pageEncoding="gb2312"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
 
<html> 
<head>
<title>JSP for ZhuCeForm form</title>
<script type="text/javascript" language="javascript">
function check(a){
for(int i;i<a.lengh;i++){
if(a.element[i].value==""){
alert("请输入完整信息!");
}
}
if(loginform.mpassword.value!=loginform.mpassword1.value){
alert("密码不一致,请重新输入!");
document.loginform.mpassword1.focus();
return true;
}
return false;
}


</script>


</head>
<body>
<html:form action="/zhuCe">
姓名 : <html:text property="mname"/><html:errors property="mname"/><br/>
邮箱 : <html:text property="mmail"/><html:errors property="mmail"/><br/>
性别 : <html:radio property="msex" value="m"/>男<html:radio property="msex" value="f"/>女<html:errors property="msex"/><br/>
地址 : <html:text property="maddress"/><html:errors property="maddress"/><br/>
年龄 : <html:text property="mage"/><html:errors property="mage"/><br/>
密码 : <html:text property="mpassword"/><html:errors property="mpassword"/><br/>
电话 : <html:text property="mtel"/><html:errors property="mtel"/><br/>
<input type="submit" value="提交" onsubmit="return check(this)"/>
<html:cancel/>
</html:form>
</body>
</html>



------解决方案--------------------
HTML code
<form name="loginform" action="/login" onsubmit="return check();">