表单与javascript菜鸟问题
请高手帮忙,在使用<html:from 标签的时候,里面不能定义:name 这个属性,但是我在用javascript验证表单的时候要用到表单的名字,不知道这个问题怎么解决? 先谢了!下面是的我原代码:<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://jakarta.
prefix="bean"%>
<%@ taglib uri="http://jakarta.
prefix="html"%>
<html>
<script type="text/javascript">
function on_submit(){
if(form1.username.value==""){
alert("用户名不能为空,请输入用户名!");
form1.username.focus();
return false;
}
if(form1.password.value==""){
alert("密码不能为空,请输入用户名!");
form1.password.focus();
return false;
}
if(form1.repassword.value==""){
alert("确认密码不能为空,请输入用户名!");
form1.repassword.focus();
return false;
}
if(form1.password.value!=form1.repassword.value){
alert ("两次密码输入不一样,请重新输入!");
form1.username.focus();
return false;
}
if(form1.username.value==""){
alert("用户名不能为空,请输入用户名!");
form1.password.focus();
return false;
}
}
</script>
<head>
<title>注册页面</title>
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
.STYLE5 {
font-size: xx-large;
font-family: "新宋体";
color: #00CC66;
}
-->
</style>
</head>
<body>
<center><h2 class="STYLE5">新用户注册</h2></center>
<html:form name="form1" action="/regist" onsubmit="return on_submit()">
<table width="520" height="372" border="0" align="center">
<tr>
<td width="131">用户名:</td>
<td width="373"><label>
<html:text property="username" />
<span class="STYLE1">*</span></label></td>
</tr>
<tr>
<td><p>真实姓名:</p> </td>
<td><label>
<html:text property="truename" />
</label></td>
</tr>
<tr>
<td>密码:</td>
<td><label>
<html:password property="password" />
<span class="STYLE1">*</span></label></td>
</tr>
<tr>
<td>确认密码:</td>
<td><label>
<html:password property="repassword" />
<span class="STYLE1">*</span></label></td>
</tr>
<tr>
<td>性别:</td>
<td><label>
<html:text property="sex" />
</label></td>
</tr>
<tr>
<td>e-mail:</td>
<td><label>
<html:text property="email" />
</label></td>
</tr>
<tr>
<td>电话:</td>
<td><label>
<html:text property="phone" />
</label></td>
</tr>
<tr>
<td>教育程度:</td>
<td><label>
<html:text property="education" />
</label></td>
</tr>
<tr>
<td>爱好:</td>
<td><label>
<input name="favorite" type="text" id="favorite" />
</label></td>
</tr>
<tr>
<td valign="top">个性签名:</td>
<td><label>
<html:textarea property="characters" cols="50" rows="8" />
</label></td>
</tr>
<tr>
<td align="right"><label>
<input type="submit" name="Submit" value="提交"/>
</label></td>
<td align="center"><label>
<input type="reset" name="Submit2" value="重置"/>
</label></td>
</tr>
</table>
</html:form>
</body>
</html>