Finding if a certain form elements exists...

S

Stu

Hi,

I want to be able to check if a form element exists in the form post data.
IN this instance I want to find out if Request.Form("Postcode") is part of
the forms collection.

I have tried:

If Request.Form("Address Line 5").Length > 0 Then Response.Write("It
exists!")

but get the error:
Object reference not set to an instance of an object.

Thanks in advance,

Stu
 
M

Marina

The problem here is, that it doesn't exist - but you are trying to get the
Length property of an object that doesn't exist

Try: If Request.Form("Address Line 5") <> "" Then

OR

If Not IsNothing(Request.Form("Address Line 5") ) Then
 
S

Stu

Many thanks.

The 'If Not IsNothing(Request.Form("Address Line 5") ) Then' worked great.

Kevin > I had tried both with and without the spaces in the form name and
the spaces don't alter the functionality. I know spaces in form names is not
good practice, but the form is built by an end user using a WYSIWYG edtor
and could be called anything...I'm almost surprised that they stopped at
spaces :)
 
K

Kevin Spencer

Make sure it works in all browsers, unless you're developing specifically
for IE. Chances are, it won't.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top