按钮onClick事件问题

mysite365 2008-04-10 03:19:40
<input type="submit" name="Submit" onClick="check();return false;" value="提交" />
当点击按钮提交,为什么不运行 事件check()呢??这地方刚学,知道的 ,把onClick用法介绍下.....
...全文
103 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuyu000000 2008-04-17
  • 打赏
  • 举报
回复
把 return true;放到login()里看看。
cjh22263 2008-04-10
  • 打赏
  • 举报
回复
很深奥啊,学习下
mysite365 2008-04-10
  • 打赏
  • 举报
回复
修正一下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../conn/my_conn.asp"-->
<!--#include file="../str_filter.asp"-->
<!--#include file="../md5.asp"-->
<% function login()
admin=str_filter(request.Form("admin"))
pwd=md5(str_filter(request.Form("pwd")))
code=str_filter(request.Form("code"))
if admin="" or pwd="" then
response.write "<script LANGUAGE='javascript'>alert('您的用户名或密码有误!');</script>"
response.end
end if

set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from [bout_admin] where admin='"&admin&"' " ,conn,1,3
if rs("code")<>code then
response.Write("<script language='javascript'>arert('你的验证码不正确,请与管理员联系!');</script>")
response.end
end if
if rs("lock")=1 then
response.Write("<script language='javascript'>arert('你的用户名已被锁定,请与管理员联系!');</script>")
response.Redirect("../index.asp")
else
if pwd=rs("pwd") then
session("admin")=admin
session("admin_name")=rs("admin_name")
session("pwd")=rs("pwd")
session("flag")=rs("flag")
response.Redirect(index.asp)
else
response.write "<script LANGUAGE='javascript'>alert('您的用户名或密码有误!');</script>"
end if
end if
end function

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="../css/admin_css.css" rel="stylesheet" type="text/css">
<title>注意安全</title>
<script language="JavaScript">
<!--
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
//-->
</script>
</head>

<body>
<table width="1004" align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="587" background="image/login_back.gif"><table width="833" height="183" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="183" colspan="2"> </td>
<td width="520" colspan="3">
<form id="form1" name="form1" method="post" action="" onsubmit="return login();">
<table width="331" height="131" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="101"> </td>
<td colspan="3"> </td>
<td width="85"> </td>
</tr>
<tr>
<td align="right">管理ID:</td>
<td colspan="3">
<input name="admin" type="text" size="16" maxlength="15" /> </td>
<td> </td>
</tr>
<tr>
<td align="right">密 码 :</td>
<td colspan="3">
<input name="pwd" type="password" size="16" maxlength="15" /> </td>
<td> </td>
</tr>
<tr>
<td align="right">验证码:</td>
<td colspan="3" align="left"> 
<input name="code" type="text" size="10" onKeyPress="event.returnValue=IsDigit();" maxlength="10" /> </td>
<td> </td>
</tr>
<tr>
<td align="right"><input type="submit" name="Submit" value="提交" /></td>
<td width="13"></td>
<td width="52" align="left"><input type="reset" name="Submit2" value="重置" /></td>
<td width="80" align="left"><input type="button" name="Submit3" onclick="window.location.href='admin_reg.asp'" value="注册" /></td>
<td> </td>
</tr>
</table>
</form>
</td>
</tr>

</table></td>
</tr>
</table>
</body>
</html>
mysite365 2008-04-10
  • 打赏
  • 举报
回复
我的代码没有return false啊。。。
Anlige 2008-04-10
  • 打赏
  • 举报
回复
把return false放到check函数里看看~~~
lsf5921 2008-04-10
  • 打赏
  • 举报
回复
你用JS试下
mysite365 2008-04-10
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../conn/my_conn.asp"-->
<!--#include file="../str_filter.asp"-->
<!--#include file="../md5.asp"-->
<% function login()
admin=str_filter(admin)
pwd=md5(str_filter(pwd))
code=str_filter(code)
if admin="" or pwd="" then
response.write "<script LANGUAGE='javascript'>alert('您的用户名或密码有误!');</script>"
response.end
end if

set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from [bout_admin] where admin='"&admin&"' " ,conn,1,3
if rs("code")<>code then
response.Write("<script language='javascript'>arert('你的验证码不正确,请与管理员联系!');</script>")
response.end
end if
if rs("lock")=1 then
response.Write("<script language='javascript'>arert('你的用户名已被锁定,请与管理员联系!');</script>")
response.Redirect("../index.asp")
else
if pwd=rs("pwd") then
session("admin")=admin
session("admin_name")=rs("admin_name")
session("pwd")=rs("pwd")
session("flag")=rs("flag")
response.Redirect(index.asp)
else
response.write "<script LANGUAGE='javascript'>alert('您的用户名或密码有误!');</script>"
end if
end if
end function

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="../css/admin_css.css" rel="stylesheet" type="text/css">
<title>注意安全</title>
<script language="JavaScript">
<!--
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}
//-->
</script>
</head>

<body>
<table width="1004" align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="587" background="image/login_back.gif"><table width="833" height="183" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="183" colspan="2"> </td>
<td width="520" colspan="3">
<form id="form1" name="form1" method="post" action="" onsubmit="return login();">
<table width="331" height="131" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="101"> </td>
<td colspan="3"> </td>
<td width="85"> </td>
</tr>
<tr>
<td align="right">管理ID:</td>
<td colspan="3">
<input name="admin" type="text" size="16" maxlength="15" /> </td>
<td> </td>
</tr>
<tr>
<td align="right">密 码 :</td>
<td colspan="3">
<input name="pwd" type="password" size="16" maxlength="15" /> </td>
<td> </td>
</tr>
<tr>
<td align="right">验证码:</td>
<td colspan="3" align="left"> 
<input name="code" type="text" size="10" onKeyPress="event.returnValue=IsDigit();" maxlength="10" /> </td>
<td> </td>
</tr>
<tr>
<td align="right"><input type="submit" name="Submit" value="提交" /></td>
<td width="13"></td>
<td width="52" align="left"><input type="reset" name="Submit2" value="重置" /></td>
<td width="80" align="left"><input type="button" name="Submit3" onclick="window.location.href='admin_reg.asp'" value="注册" /></td>
<td> </td>
</tr>
</table>
</form>
</td>
</tr>

</table></td>
</tr>
</table>
</body>
</html>
我点提交按钮,没有执行,上面的登陆验证。。。。。。。。。
小逗狗 2008-04-10
  • 打赏
  • 举报
回复
会运行的啊,你把所以代码贴出来,表单检查数据都是这样的啊!
hookee 2008-04-10
  • 打赏
  • 举报
回复
对不起,上面错了
<form onsubmit="return check();">
<input type="submit" name="Submit" value="提交" />

function check(){
if(ok) return true;
else return false;
}
hookee 2008-04-10
  • 打赏
  • 举报
回复
<input type="submit" name="Submit" onClick="return check();" value="提交" />

function check(){
if(ok) return true;
else return false;
}

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧