为什么表单验证程序显示错误还提交?
//我想实现当title中的内容为空,禁止提交,可不知为什么虽然提示 "请填写产品类型 ",但还是提交了,我也不知为什么,希望高手指点,谢谢了!!!!!11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<%@ codepage = 936 LCID = 2052 %>
<% if Session( "exemple_status ") <> "login " then response.redirect "login.asp " %>
<!--#include file= "pagefoot.asp "-->
<!--#include file= "header.asp "-->
<script language= "JavaScript ">
function CheckLoginForm()
{
if (document.form1.title.value == " ")
{
alert( "请填写产品类型! ");
document.form1.title.focus();
return false;
}
}
</script>
<table width= "100% " border= "0 " cellspacing= "0 " cellpadding= "0 " bgcolor= "#336699 "> <tr> <td>
<img src= "images/bnrlist.gif " alt= " " width= "400 " height= "30 " border= "0 "> </td> </tr> </table>
<%strsql = "select * from [pro_type] "
set rs=server.createobject( "adodb.recordset ")
set conn=server.createobject( "adodb.connection ")
conn.open xDb_Conn_Str
rs.open strsql,conn,3,3
'如果第一次进入就显示下面代码!!!
if request.servervariables( "request_method ")= "GET " then
%>
<form name= "form1 " action=ptype_add.asp method= "post " >
<table bgColor= "#000000 " border= "0 " align=center width=100%>
<tr>
<td vAlign= "top " width= "25% " bgColor= "#f7f7f7 " >
类型名称: <input type=text value= " " name=title >
</td> </tr>
<tr> <td vAlign= "top " width= "5% " bgColor= "#f7f7f7 " align=center>
<input type = "submit " value = "添加 " onclick= "CheckLoginForm() ">
<input type = "button " value = "返回 " onClick = "javascript:window.history.go(-1) " >
</td>
</tr>
</table>
</form>
<%else
'点吉添加按纽
rs.addnew
rs( "type_name ")=trim(request( "title "))
rs.update
response.write( " <script language= 'JavaScript '> alert( '添加成功!! ');location.href= 'pro_typelist.asp '; </script> ")
end if
rs.close
set rs=nothing
%>
<!--#include file= "footer.asp "-->
------解决方案--------------------onclick= "CheckLoginForm() "改为
onclick= &quo