判断传送的字符不能为空的小问题,没学过asp.在线等!

szc21 2006-08-25 11:23:36
页面1:st.asp

<FORM name=myform action="ss.asp" method=post ID="Form1">
<input type=hidden value=12 name="s1">
<input type=hidden value=<%=skin%> name="s2"> //注意这句
<input type=submit id="s3" value="发送">
</FORM>
页面2:ss.asp
<%
va1=request("s1")
va2=request("s2")
Response.Write(va1)
Response.Write(va2)
%>
我想判断s2的绑定数值为空的时候,点击发送后,出现提示"s2为空",页面不跳转到ss.asp,直到不为空才执行.请问高人,怎么实现?
...全文
221 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
icefire988 2006-08-25
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
<!--//
function check()
{
if(document.myform.s2.value == "")
{
document.getElementById("msg").innerText = "s2不能为空!" ;
return false;
}
return true;
}
//-->
</script>
</head>

<body>
<form name="myform" action="ss.asp" method="post" id="form1" onsubmit="return check();">
<input type="hidden" value="12" name="s1">
<input type="hidden" value="<%=skin%>" name="s2">
<input type="submit" id="s3" value="发送">
</form>
<div id="msg"></div>
</body>
</html>
flyingsnowy 2006-08-25
  • 打赏
  • 举报
回复
<script language=javascript>
function check()
{
if(document.myform.s2.value == "")
{
alert("s2为空");
document.myform.s2.focus();
return false;
}
return true;
}
</script>


================以上在客户端验证。

当然也可以在服务器端验证。
就像你的

页面2:ss.asp
<%
va1=request("s1")
va2=request("s2")
if va1="" then
response.write "<script>alert('XX为空');</script>"
end if
if va2="" then
response.write "<script>alert('XX为空');</script>"
end if

Response.Write va1 &"<br>"&va2

%>

吃饭去了。
文盲老顾 2006-08-25
  • 打赏
  • 举报
回复
onsumit

同意楼上意见
szc21 2006-08-25
  • 打赏
  • 举报
回复
谢谢!我测试下!估计可行
郭大侠_ 2006-08-25
  • 打赏
  • 举报
回复
提交前验证,用
justcode(小码)
的方法就行了
atubo1234 2006-08-25
  • 打赏
  • 举报
回复
<FORM name=myform action="ss.asp" method=post ID="Form1"
onsubmit="return check();">--------------------------------------++
<input type=hidden value=12 name="s1">
<input type=hidden value=<%=skin%> name="s2">
<input type=submit id="s3" value="发送">
</FORM>
--------------------------------------------------------------++
<script language=javascript>
function check()
{
if(document.myform.s2.value == "")
{
alert("s2为空");
document.myform.s2.focus();
return false;
}
return true;
}
</script>
小码 2006-08-25
  • 打赏
  • 举报
回复
<FORM name=myform action="ss.asp" method=post ID="Form1" onsubmit="return chk(this)">
<input type=hidden value=12 name="s1" id="s1">
<input type=hidden value=<%=skin%> name="s2" id="s2"> //注意这句
<input type=submit id="s3" value="发送">
</FORM>
<script>
function chk(f){if (f.s2.value==""){alert("s2不能为空");f.s2.focus();return false;}}
</script>
szc21 2006-08-25
  • 打赏
  • 举报
回复
好象不是很难吧?就是数据验证的问题.我是学.net的,换那个的话早就解决了,只不过不清楚这东东,高人快来,UP的也给分
wawowawoo 2006-08-25
  • 打赏
  • 举报
回复
学习
帮顶!

28,391

社区成员

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

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