日期:2014-05-17  浏览次数:20881 次

如何用ASP判断表单为空的?
<form   id= "form1 "   name= "form1 "   method= "post "   action= "check.asp ">
    <p   align= "center "> 网站名称:
        <input   name= "sitename "   type= "text "   id= "sitename "   />
    </p>
    <p   align= "center "> 网站地址:
        <input   name= "url "   type= "text "   id= "url "   />
    </p>
    <p   align= "center "> 联   系   人:
        <input   name= "lxr "   type= "text "   id= "lxr "   />
    </p>
    <p   align= "center "> 联系电话:
        <input   name= "tel "   type= "text "   id= "tel "   />
    </p>
    <p   align= "center "> 联系地址:
        <input   name= "add "   type= "text "   id= "add "   />
    </p>
    <p   align= "center "> 传&nbsp;&nbsp;&nbsp;   真:
        <input   name= "fax "   type= "text "   id= "fax "   />
    </p>
    <p   align= "center "> 邮&nbsp;&nbsp;   &nbsp;箱:
        <input   name= "mail "   type= "text "   id= "mail "   />
</p>
    <p   align= "center ">
        <input   type= "submit "   name= "Submit "   value= "提交 "   class= "anniu "   />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
        <input   type= "reset "   name= "Submit2 "   value= "重置 "     class= "anniu "/>
    </p>
</form>


请问这个表单该如何用ASP判断
如果不是空的话就去执行一条SQL语句

我看别的源代码里好像是这样写的   if   action   <>   " "   then
这样对不对?为什么要这样写?


------解决方案--------------------
<%
sub textse(msg,text)
if request.form(text)= " " then
response.write " <Script> window.alert( ' "& msg & "不能为空 ');location.replace( '当前页面.asp '); </Script> "
response.end
end sub
%>
<%
if request( "action ")= "save " then
%>
<%call textse( "网站名称 ", "sitename ")%>
<%call textse( "网站地址 ", "url ")%>
<%call textse( "联系人 ", "lxr ")%>
<%call textse( "联系电话 ", "tel ")%>
<%call textse( "联系地址 ", "add ")%>
<%call textse( "传真 ", "fax ")%>
<%call textse( "邮箱 ", "mail ")%>
<%
sql= "..................... "
....执行SQL
end if
%>

再就是用JS去做判断,你指定要ASP就写ASP了