Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: problem validating form fields


Message #1 by "Kelvin" <kelvinteh@h...> on Wed, 28 Mar 2001 17:18:22
hi,



i have this problem in validating form fields. How do i check whether the 

passed in form field exist? for e.g. In my action page, i request for the 

form field named "handphoneNum".



request.form("handphoneNum")



i tried using these methods to check whether this form field exist, but 

they could not work.



if request.form("handphoneNum") = null then

...

end if



if request.form("handphoneNum") = empty then

...

end if



if request.form("handphoneNum") = nothing then

...

end if





i'm stuck with this problem. 

can someone help me in this problem? 

Your help will be much appreciated.



thank you.



Message #2 by "Peter Lanoie" <planoie@e...> on Wed, 28 Mar 2001 12:12:48 -0500
The only way I can think of testing it is to see if the field is blank

(="").  If you are expecting there to be a value, then you could be pretty

sure that if it's blank, it's not there.  Combine with some JavaScript

validation to ensure that the form isn't submitted with that field blank if

it exists.



I can give you further information on checking to see if it exists in

JavaScript if you so desire. That I know can be done.



HTH,

Peter



-----Original Message-----

From: Kelvin [mailto:kelvinteh@h...]

Sent: Wednesday, March 28, 2001 12:18 PM

To: ASP Web HowTo

Subject: [asp_web_howto] problem validating form fields





hi,



i have this problem in validating form fields. How do i check whether the

passed in form field exist? for e.g. In my action page, i request for the

form field named "handphoneNum".



request.form("handphoneNum")



i tried using these methods to check whether this form field exist, but

they could not work.



if request.form("handphoneNum") = null then

...

end if



if request.form("handphoneNum") = empty then

...

end if



if request.form("handphoneNum") = nothing then

...

end if





i'm stuck with this problem.

can someone help me in this problem?

Your help will be much appreciated.



thank you.





Message #3 by "Wally Burfine" <oopconsultant@h...> on Wed, 28 Mar 2001 18:42:45 -0000
Kelvin,



You are close, use:



if isempty(request.form("handphoneNum")) then

...



regards, Wally





>From: "Kelvin" <kelvinteh@h...>

>Reply-To: "ASP Web HowTo" <asp_web_howto@p...>

>To: "ASP Web HowTo" <asp_web_howto@p...>

>Subject: [asp_web_howto] problem validating form fields

>Date: Wed, 28 Mar 2001 17:18:22

>

>hi,

>

>i have this problem in validating form fields. How do i check whether the

>passed in form field exist? for e.g. In my action page, i request for the

>form field named "handphoneNum".

>

>request.form("handphoneNum")

>

>i tried using these methods to check whether this form field exist, but

>they could not work.

>

>if request.form("handphoneNum") = null then

>...

>end if

>

>if request.form("handphoneNum") = empty then

>...

>end if

>

>if request.form("handphoneNum") = nothing then

>...

>end if

>

>

>i'm stuck with this problem.

>can someone help me in this problem?

>Your help will be much appreciated.

>

>thank you.

>

>
Message #4 by "Ken Schaefer" <ken@a...> on Fri, 30 Mar 2001 13:29:25 +1000

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

: i have this problem in validating form fields. How do i check whether the

: passed in form field exist? for e.g. In my action page, i request for the

: form field named "handphoneNum".

:

: request.form("handphoneNum")

:

: i tried using these methods to check whether this form field exist, but

: they could not work.

:

: if request.form("handphoneNum") = null then

: ...

: end if



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



It's not working, because they aren't equal to NULL. Nothing is equal to

NULL, not even another NULL. OK?



<%

If Request.Form("field1") & "" = "" then

    ' empty

Else

    ' something there

End if

%>



The & "" forces an implicit conversion of any NULLs to string.



Cheers

Ken





Message #5 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Fri, 30 Mar 2001 10:43:08 +0100
isempty is the same as ="" (empty string)



what he wants is 



if isnull(request.form("handphoneNum")) then



but it really depends on what the database is returning, nulls or empty

strings?



to be safe do 



if isnull(request.form("handphoneNum")) or

isempty(request.form("handphoneNum")) then



-----Original Message-----

From: Wally Burfine [mailto:oopconsultant@h...]

Sent: Wednesday, March 28, 2001 7:43 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Re: problem validating form fields





Kelvin,



You are close, use:



if isempty(request.form("handphoneNum")) then

...



regards, Wally





>From: "Kelvin" <kelvinteh@h...>

>Reply-To: "ASP Web HowTo" <asp_web_howto@p...>

>To: "ASP Web HowTo" <asp_web_howto@p...>

>Subject: [asp_web_howto] problem validating form fields

>Date: Wed, 28 Mar 2001 17:18:22

>

>hi,

>

>i have this problem in validating form fields. How do i check whether the

>passed in form field exist? for e.g. In my action page, i request for the

>form field named "handphoneNum".

>

>request.form("handphoneNum")

>

>i tried using these methods to check whether this form field exist, but

>they could not work.

>

>if request.form("handphoneNum") = null then

>...

>end if

>

>if request.form("handphoneNum") = empty then

>...

>end if

>

>if request.form("handphoneNum") = nothing then

>...

>end if

>

>

>i'm stuck with this problem.

>can someone help me in this problem?

>Your help will be much appreciated.

>

>thank you.

>

________________________________________________________________________

Scottish Enterprise Network

http://www.scottish-enterprise.com

Message #6 by "Drew, Ron" <RDrew@B...> on Fri, 30 Mar 2001 10:46:34 -0500
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C0B930.993D3CF0

Content-Type: text/plain



On the page with the form, add the following Javascript in the HEAD

<script language="JavaScript">

<!-- for old browsers

function CheckForm() {

if (document.myform.handphoneNum.value == "")

      {

       alert("Please enter a value for Hand Phone Number.");

       document.myform.handphoneNum.focus();

       return (false);

      }

 return (true); 

}

//-->

</script>



Then add the onSubmit in the BODY

<FORM onSubmit="return CheckForm()" METHOD="POST" ACTION="some.asp"

NAME=myform>



Ron

-----Original Message-----

From: Kelvin [mailto:kelvinteh@h...]

Sent: Wednesday, March 28, 2001 12:18 PM

To: ASP Web HowTo

Subject: [asp_web_howto] problem validating form fields





hi,



i have this problem in validating form fields. How do i check whether the 

passed in form field exist? for e.g. In my action page, i request for the 

form field named "handphoneNum".



request.form("handphoneNum")



i tried using these methods to check whether this form field exist, but 

they could not work.



if request.form("handphoneNum") = null then

...

end if



if request.form("handphoneNum") = empty then

...

end if



if request.form("handphoneNum") = nothing then

...

end if





i'm stuck with this problem. 

can someone help me in this problem? 

Your help will be much appreciated.



thank you.





---

SoftArtisans helps developers build robust, scalable Web applications!

Excel Web reports, charts: http://www.softartisans.com/excelwriter.html

File uploads: http://www.softartisans.com/saf.html

Transactional file management: http://www.softartisans.com/saf1.html

Scalability: http://www.softartisans.com/saxsession.html

ASPstudio value pack: http://www.softartisans.com/aspstudiosuite.html




$subst('Email.Unsub')





  Return to Index