用vbscript如何写下面函数最简洁高效..

ccz500 2002-05-16 04:27:05
想要在表单提交时严正表但中各个域的值是否为空.如为空则提示出错信息.并将光标指向form中第一个为空的域..
<form action="" name=form onsubmit="return check(this)">
<script language=vbscript>
function check(obj)
end function
</script>
...全文
10 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Ljat 2002-05-16
dim SrcId
Set SrcId = Window.event.SrcElement
If SrcId.value = empty Then
MsgBox "報錯!!",48
Srcid.focus()
Exit Sub
End If
回复
snailili 2002-05-16
<%
for each name in request.form
if request.form(name)="" then
exit for
end if
next
%>
......

这样好像可以减少点代码......
回复
ccz500 2002-05-16
我的form中含有很多文本框.这样写............
回复
ccz500 2002-05-16
还有没有别的方法??
比如遍历form中各域的值..
然后判断..
回复
wangfei2428 2002-05-16
使用该文件
<HTML><HEAD><TITLE>订单输入</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId>
<LINK href="../image/Member.files/Style.css" rel=stylesheet>
<SCRIPT LANGUAGE=VBSCRIPT>
sub pop()
edit.name.value=edit.sex.value+edit.fenlei.value+edit.state.value
end sub
sub check()
if edit.prodid.value=empty then
msgbox "您没有填写产品的货号",32+1
edit.elements(0).focus
else
if edit.fenlei.value=empty then
msgbox "您没有选择产品所属季节分类",32+1
edit.elements(1).focus
else
if edit.sex.value=empty then
msgbox "您没有选择产品所属性别分类",32+1
edit.elements(2).focus
else
if edit.state.value=empty then
msgbox "您没有选择产品所属加工行为分类",32+1
edit.elements(3).focus
else
window.open "","SetStatus",_
"status=no,resizable=0,toolbar=no,menubar=no,scrollbars=no,width=500,height=300,left=200,top=150"
edit.submit
end if
end if
end if
end if
end sub
</SCRIPT>
</HEAD>
<BODY topmargin="1" leftmargin="1">
<p> </p>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="634" height="117">
<TBODY>
<TR>
<TD vAlign=top width="469" height="117">
<FORM action=add.asp method=post name=Edit target=SetStatus>
<TABLE align=center border=1 borderColor=#000000 borderColorDark=#ffffff
borderColorLight=#000000 cellPadding=0 cellSpacing=0
style="border: 1px solid #000000"
width="632" height="85">
<TBODY>
<TR bgColor=#4713a0>
<TD align=middle bgColor=#FFFFFF width="618" height="5" colspan="4"> </TD>
</TR>
<TR bgColor=#4713a0>
<TD bgColor=#c0c0c0 width="618" height="20" colspan="4">  </TD>
</TR>
<TR>
<TD width="78" height="40" align="center">产品货号</TD>
<TD width="540" height="29" colspan="3"> <input type="text" name="prodid" size="30" style="border-style: solid; border-width: 1"></TD>
</TR>
<TR>
<TD width="78" height="40" align="center">按季节分类</TD>
<TD width="226" height="29"> <select size="1" name="fenlei" onchange="pop()">
<option value="单鞋">---单鞋---</option>
<option value="棉鞋">---棉鞋---</option>
<option value="凉鞋">---凉鞋---</option>
</select></TD>
<TD width="90" height="29" align="center">   </TD>
<TD width="227" height="29">    </TD>
</TR>
<TR>
<TD width="78" height="40" align="center">按性别分类</TD>
<TD width="226" height="29"> <select size="1" name="sex" onchange="pop()">
<option value="男">----男----</option>
<option value="女">----女----</option>
</select></TD>
<TD width="90" height="29" align="center">按加工行为分类</TD>
<TD width="227" height="29"> <select size="1" name="state" onchange="pop()">
<option value="注">----注----</option>
<option value="夹">---夹---</option>
<option value="外加工">外加工</option>
</select></TD>
</TR>
<TR>
<TD width="78" height="40" align="center">产品名称</TD>
<TD width="540" height="29" colspan="3"> <input type="text" name="name" size="51" style="border-style: solid; border-width: 1" onfocus="pop()"></TD>
</TR>
<TR>
<TD width="78" height="15" align="center">备注</TD>
<TD width="540" height="15" colspan="3"><textarea rows="5" name="connet" cols="67"></textarea></TD>
</TR>
<TR>
<TD width="618" height="35" align="center" colspan="4"><input type="button" value="增加产品货号" name="B1" style="border-style: solid; border-width: 1" onclick="check()">
<input type="reset" value="信息全部重写" name="B2" style="border-style: solid; border-width: 1"></TD>
</TR>
</TBODY></TABLE></FORM>
</TD></TR></TBODY></TABLE></BODY></HTML>

回复
wangfei2428 2002-05-16
使用该代码:

<HTML><HEAD><TITLE>订单输入</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
<META content=FrontPage.Editor.Document name=ProgId>
<LINK href="../image/Member.files/Style.css" rel=stylesheet>
<SCRIPT LANGUAGE=VBSCRIPT>
sub pop()
edit.name.value=edit.sex.value+edit.fenlei.value+edit.state.value
end sub
sub check()
if edit.prodid.value=empty then
msgbox "您没有填写产品的货号",32+1
edit.elements(0).focus
else
if edit.fenlei.value=empty then
msgbox "您没有选择产品所属季节分类",32+1
edit.elements(1).focus
else
if edit.sex.value=empty then
msgbox "您没有选择产品所属性别分类",32+1
edit.elements(2).focus
else
if edit.state.value=empty then
msgbox "您没有选择产品所属加工行为分类",32+1
edit.elements(3).focus
else
window.open "","SetStatus",_
"status=no,resizable=0,toolbar=no,menubar=no,scrollbars=no,width=500,height=300,left=200,top=150"
edit.submit
end if
end if
end if
end if
end sub
</SCRIPT>
</HEAD>
<BODY topmargin="1" leftmargin="1">
<p> </p>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 width="634" height="117">
<TBODY>
<TR>
<TD vAlign=top width="469" height="117">
<FORM action=add.asp method=post name=Edit target=SetStatus>
<TABLE align=center border=1 borderColor=#000000 borderColorDark=#ffffff
borderColorLight=#000000 cellPadding=0 cellSpacing=0
style="border: 1px solid #000000"
width="632" height="85">
<TBODY>
<TR bgColor=#4713a0>
<TD align=middle bgColor=#FFFFFF width="618" height="5" colspan="4"> </TD>
</TR>
<TR bgColor=#4713a0>
<TD bgColor=#c0c0c0 width="618" height="20" colspan="4">  </TD>
</TR>
<TR>
<TD width="78" height="40" align="center">产品货号</TD>
<TD width="540" height="29" colspan="3"> <input type="text" name="prodid" size="30" style="border-style: solid; border-width: 1"></TD>
</TR>
<TR>
<TD width="78" height="40" align="center">按季节分类</TD>
<TD width="226" height="29"> <select size="1" name="fenlei" onchange="pop()">
<option value="单鞋">---单鞋---</option>
<option value="棉鞋">---棉鞋---</option>
<option value="凉鞋">---凉鞋---</option>
</select></TD>
<TD width="90" height="29" align="center">   </TD>
<TD width="227" height="29">    </TD>
</TR>
<TR>
<TD width="78" height="40" align="center">按性别分类</TD>
<TD width="226" height="29"> <select size="1" name="sex" onchange="pop()">
<option value="男">----男----</option>
<option value="女">----女----</option>
</select></TD>
<TD width="90" height="29" align="center">按加工行为分类</TD>
<TD width="227" height="29"> <select size="1" name="state" onchange="pop()">
<option value="注">----注----</option>
<option value="夹">---夹---</option>
<option value="外加工">外加工</option>
</select></TD>
</TR>
<TR>
<TD width="78" height="40" align="center">产品名称</TD>
<TD width="540" height="29" colspan="3"> <input type="text" name="name" size="51" style="border-style: solid; border-width: 1" onfocus="pop()"></TD>
</TR>
<TR>
<TD width="78" height="15" align="center">备注</TD>
<TD width="540" height="15" colspan="3"><textarea rows="5" name="connet" cols="67"></textarea></TD>
</TR>
<TR>
<TD width="618" height="35" align="center" colspan="4"><input type="button" value="增加产品货号" name="B1" style="border-style: solid; border-width: 1" onclick="check()">
<input type="reset" value="信息全部重写" name="B2" style="border-style: solid; border-width: 1"></TD>
</TR>
</TBODY></TABLE></FORM>
</TD></TR></TBODY></TABLE></BODY></HTML>
回复
coffee_cn 2002-05-16
高效简洁我不知道怎么写?
msg="error"
if document.form.text1.value="" then
msgbox msg
document.form.text1.focus
elseif document.form.text2.value="" then
msgbox msg
document.form.text2.focus
elseif document.form.text3.value="" then
msgbox msg
document.form.text3.focus
end if
回复
cmsoft 2002-05-16
你用javascript吧,VS不允许这样
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2002-05-16 04:27
社区公告
暂无公告