-1

每个人我都是 ASP 的新手,我写了一个应该从 HTML 表单中获取输入的代码。

我给了一个文本框,该文本框的值是强制性的。如果用户没有输入该字段。asp 页面应显示消息“该字段不能留空!

我写了一个代码,但我没有得到输出。谁能帮我?

我的代码片段是

索引.html

 <form method="post" action="a1.asp">
   Field 1<input type="text" name="field1">*
   </br></br><input type="submit" name="send" value="submit">
   <input type="reset" name="clear" value="clear">
   </form>

a1.asp

 <%
Function Mandatory(field1)
if field1 = "" then
response.write("Field one is mandatory!cannot be left empty")
else
response.write("Welcome to new html")
End if
End Function
%>
4

2 回答 2

2

您必须使用 Request.Form 从“POST”操作中获取值。

喜欢:

field1 = request.form("field1")
if field1 = "" then 
....

参考这个:http ://www.w3schools.com/asp/coll_form.asp

顺便说一句,asp是非常非常古老的。如果你想学习 web 开发语言,你可以试试 ASP.NET 或 php。

于 2012-08-03T07:15:44.050 回答
1

没有更多信息很难说。但是您需要在某处调用该函数,并引用 Request 集合,例如:

<% Mandatory(Request("field1")) %>
于 2012-08-03T07:16:54.523 回答