How to check if a POST submitted field exists in VBScript?

前端 未结 4 2020
情书的邮戳
情书的邮戳 2020-12-11 17:33

After a form is submitted, how does one check server-side if a particular field exists? For example:

If [Exists] Request(\"FieldName\") Then
    ...
End If
<         


        
4条回答
  •  我在风中等你
    2020-12-11 17:41

    To check if the parameter was present (without caring about its value) it is also possible to write:

    fieldValue = Request("FieldName")
    if Not IsEmpty(fieldValue) ...
    

    One advantage over Count method above is, that you can test the variable, without referring to the field name again. Advantage over testing for "" is that if you pass &FieldName without assigning value, test for "" will yield true, but IsEmpty returns false.

    Edit: Turns out this is not reliable in IIS.

    1. For the url with ?param alone, or ?param=¶m2, IsEmpty(param) returns false, but
    2. For the url with ?param¶m2, IsEmpty(param) weirdly returns true ...

提交回复
热议问题