为什么用户名和密码没有验证就能提交?是哪里错了?请指教!
请高手帮忙看看这段代码,是哪里出了问题,为什么提交时没有经过验证直接就转到add.jsp页面上去了?(add.jsp是随便写了两个字的一个普通页。)<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE2 {
font-size: 24px;
font-family: "新宋体";
color: #FF0000;
}
.STYLE3 {
color: #0033FF;
font-size: 12px;
font-family: "新宋体";
}
.STYLE4 {color: #FF0000}
.STYLE6 {font-size: 14px; font-family: "新宋体"; }
.STYLE8 {font-size: 14px; font-family: "新宋体"; color: #0000FF; }
.STYLE10 {font-size: 14px; font-family: "新宋体"; color: #0033FF; }
.STYLE12 {font-size: 12px; font-family: "新宋体"; }
-->
</style>
<script language="JAVASCRIPT">
<!--
function check_Null(){
if (document.form1.user_id.value==""){
alert("用户名不能为空!");
return false;
}
if (document.form1.passwd.value==""){
alert("密码不能为空!");
return false;
}
}
if (document.form1.user_name.value==""){
alert("真实姓名不能为空!");
return false;
}
if (document.form1.gs_name.value==""){
alert("公司名称不能为空!");
return false;
}
if (document.form1.gs_call.value==""){
alert("办公电话不能为空!");
return false;
}
return true;
}
// -->
</script>
</head>
<body>
<table width="800" height="409" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30"><table width="100%" height="30" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="3%" align="left" valign="bottom"><img src="image/login_001C.jpg" width="30" height="60" /></td>
<td width="94%" bgcolor="#2482AA"> </td>
<td width="3%" align="right" valign="bottom"><img src="image/login_003C.jpg" width="30" height="60" /></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" valign="top"><table width="800" height="436" border="1" cellpadding="0" cellspacing="0" bordercolor="#2482AA">
<tr>
<td height="434" valign="top" bgcolor="#EFEFEF">
<form id="form1" name=form1 onsubmit="return check_Null()" method="post" action="add.asp">
<div align="center"><span class="STYLE2"><br />
新用户注册<br />
<br />
</span> </div>
<table width="500" height="211" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td colspan="2" align="left" valign="bottom"><span class="STYLE8">创建您的账号信息:</span><span class="STYLE12">(以下信息中,带*项为必填项)</span></td>
</tr>
<tr>
<td width="103"><div align="left" class="STYLE6">用户名:</div></td>
<td width="377"><div align="left">
<p>
<input name="user_id" type="text" size=20 id="user_id" />
<span class="STYLE3">检测用户名是否可用</span><span class="STYLE4">*</span></p>
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">密码:</div></td>
<td><div align="left">
<input name="passwd" type="password" id="passwd" size="25" />
<span class="STYLE4">*</span></div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">再次输入密码:</div></td>
<td><div align="left">
<input name="repasswd" type="password" id="repasswd" size="25" />
<span class="STYLE4">*</span></div></td>
</tr>
<tr>
<td colspan="2" align="left"><span class="STYLE10">填写您的资料:</span></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">真实姓名:</div></td>
<td><div align="left">
<input name="user_name" type="text" id="user_name" size="25" />
<span class="STYLE4">*</span></div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">公司名称:</div></td>
<td><div align="left">
<input name="gs_name" type="text" id="gs_name" size="25" />
<span class="STYLE4">*</span></div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">所在部门:</div></td>
<td><div align="left">
<input name="bumen" type="text" id="bumen" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">职务:</div></td>
<td><div align="left">
<input name="zhiwu" type="text" id="zhiwu" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">办公电话:</div></td>
<td><div align="left">
<input name="gs_call" type="text" id="gs_call" size="25" />
<span class="STYLE4">*</span></div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">办公传真:</div></td>
<td><div align="left">
<input name="gs_fax" type="text" id="gs_fax" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">手机:</div></td>
<td><div align="left">
<input name="phone" type="text" id="phone" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">QQ:</div></td>
<td><div align="left">
<input name="QQ" type="text" id="QQ" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">msn:</div></td>
<td><div align="left">
<input name="msn" type="text" id="msn" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">email:</div></td>
<td><div align="left">
<input name="email" type="text" id="email" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">公司地址:</div></td>
<td><div align="left">
<input name="gs_address" type="text" id="gs_address" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left" class="STYLE6">邮编:</div></td>
<td><div align="left">
<input name="textfield" type="text" size="25" />
</div></td>
</tr>
<tr>
<td><div align="left"></div></td>
<td><div align="left"></div></td>
</tr>
<tr>
<td colspan="2">
<div align="left">
<input type="submit" name="Submit" value="提交" />
<input type="reset" value="重置" />
</div></td>
</tr>
</table>
</form>
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>