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

前端 未结 4 2016
情书的邮戳
情书的邮戳 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:46

    I usually check the value of the SUBMIT button. If it was clicked, it's value is posted along with the form data. So, even if all your form data is blank, the submit button's value will not be. And if the submit button's value is blank, then it wasn't clicked.

    if request("btn_Submit") <> "" Then
        response.write "form was submitted"
    end if
    

    This is more difficult if you are using a javascript form.submit() call, in which case I usually opt for the hidden field.

提交回复
热议问题