469,287 Members | 2,785 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,287 developers. It's quick & easy.

determine if a form object exists

JT
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..
Jul 19 '05 #1
7 12064
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" <jt@nospam.com> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
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..

Jul 19 '05 #2
JT wrote:
is there a way to determine if a form object actually exists?
Yes. The form object never exists.

There is a .Form collection of the Request Object, and it contains .Item and
..Count elements for each *named* form element in the POSTing form.
http://msdn.microsoft.com/library/en...bom_reqocf.asp
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


On the other hand, you can examine

Request.Form("txtFormField").Count

to get the information you desire.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #3
> On the other hand, you can examine

Request.Form("txtFormField").Count

to get the information you desire.


Of course! <smacks forehead for building a kludge>
Jul 19 '05 #4
Aaron [SQL Server MVP] wrote:

Of course! <smacks forehead for building a kludge>


Must be quitting time, Aaron. Go buy yourself a beer. In fact, I'll buy
myself one in your honor on the way home (I'll accept any excuse to buy
myself a beer).

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #5
> (I'll accept any excuse to buy myself a beer).

In that case, get yourself a beer for me too

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:OT**************@TK2MSFTNGP10.phx.gbl...
Aaron [SQL Server MVP] wrote:

Of course! <smacks forehead for building a kludge>
Must be quitting time, Aaron. Go buy yourself a beer. In fact, I'll buy
myself one in your honor on the way home (I'll accept any excuse to buy
myself a beer).

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.

Use of this email address implies consent to these terms. Please do not contact me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.

Jul 19 '05 #6
Steven Burn wrote:
(I'll accept any excuse to buy myself a beer).


In that case, get yourself a beer for me too


But judging from your .sig, I think it would be appropriate to hold off
until I'm in the U.K. in two weeks. Then I'll be able to enjoy a good
cask-conditioned ale like Courage Director's Bitter**.

**My eyes glazed over and I made dreamy "Mmmmm" noises to the distraction of
my office mates as I typed that.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #7
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..
.

Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Christopher W. Douglas | last post: by
3 posts views Thread by Web Webon | last post: by
1 post views Thread by kyma via .NET 247 | last post: by
9 posts views Thread by Adam | last post: by
3 posts views Thread by Bob Day | last post: by
13 posts views Thread by softwaredoug | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.