determine if a form object exists

Discussion in 'ASP General' started by JT, Jun 30, 2004.

  1. JT

    JT Guest

    is there a way to determine if a form object actually exists?

    if i use the following syntax:

    varTextField = Request.Form("txtFormField")

    then varTextField = "" which gives the same result whether the input field
    "txtFormField" doesn't exist or it does exist but it was left empty

    why can't i use something like?

    if Exists(Request.Form("txtFormField")) = true then
    'whatever..
    JT, Jun 30, 2004
    #1
    1. Advertising

  2. Function formFieldExists(fieldName)
    formFieldExists = (InStr(Request.Form, fieldname & "=") > 0)
    End Function
    Response.Write(formFieldExists("txtFormField"))

    Now, this will work as long as someone doesn't pass "txtFormField=" in the
    DATA for a form field with a different name.

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "JT" <> wrote in message
    news:...
    > is there a way to determine if a form object actually exists?
    >
    > if i use the following syntax:
    >
    > varTextField = Request.Form("txtFormField")
    >
    > then varTextField = "" which gives the same result whether the input field
    > "txtFormField" doesn't exist or it does exist but it was left empty
    >
    > why can't i use something like?
    >
    > if Exists(Request.Form("txtFormField")) = true then
    > 'whatever..
    >
    >
    Aaron [SQL Server MVP], Jun 30, 2004
    #2
    1. Advertising

  3. JT

    tONG Guest

    Use IsEmpty(Request.Form("txtFormField"))
    >-----Original Message-----
    >is there a way to determine if a form object actually

    exists?
    >
    >if i use the following syntax:
    >
    >varTextField = Request.Form("txtFormField")
    >
    >then varTextField = "" which gives the same result

    whether the input field
    >"txtFormField" doesn't exist or it does exist but it was

    left empty
    >
    >why can't i use something like?
    >
    >if Exists(Request.Form("txtFormField")) = true then
    >'whatever..
    >
    >
    >.
    >
    tONG, Jul 2, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?T3BpZQ==?=

    Determine if record exists

    =?Utf-8?B?T3BpZQ==?=, Feb 12, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    8,123
    Joe Fallon
    Feb 13, 2005
  2. Shapper
    Replies:
    4
    Views:
    32,873
  3. Totan
    Replies:
    0
    Views:
    923
    Totan
    Apr 17, 2006
  4. Ulf Meinhardt
    Replies:
    8
    Views:
    6,118
  5. George
    Replies:
    7
    Views:
    146
    Thomas 'PointedEars' Lahn
    Oct 3, 2009
Loading...

Share This Page