Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Array Validation


Message #1 by "Joe" <joe@k...> on Tue, 20 Nov 2001 11:25:46
Hi Folks



Does anyone out there have a nifty way of validating and array?



Basically I have an array built from a query. The array is of variable 

size, returning a set of checkboxes all named txtNote.



The array is then passed over to another asp page. At this point I would 

like to check that at least 1 of the checkboxes has been checked.



All my usual ways of validating forms are scupered as the checkboxes all 

have the same name.



Any help would be great.



Joe
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 21 Nov 2001 12:47:53 +1100
Joe,



When one "validates" something you test something against a criteria,

returning either a True result (valid), or a False result (invalid).



You have an "array", and you want to "validate" it. Against what criteria?

Do you want to know whether it is an array? If so, then isArray() is all you

need - returns True or False.



If you want to check that there is at least one value in the array, you

could use Join() to get a comma delimited string, and then see if there are

any values using InStr() or similar.



If you want to know how many checkboxes are checked, you could do this:

If Request.Form("chkBoxName").Count = 0 then

    ' None where checked

Else

    ' 1 or more where checked

End If



Really, you need to provide what you are testing against, before we can tell

you how to do it.



Cheers

Ken



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

From: "Joe" <joe@k...>

Subject: [asp_web_howto] Array Validation





: Hi Folks

:

: Does anyone out there have a nifty way of validating and array?

:

: Basically I have an array built from a query. The array is of variable

: size, returning a set of checkboxes all named txtNote.

:

: The array is then passed over to another asp page. At this point I would

: like to check that at least 1 of the checkboxes has been checked.

:

: All my usual ways of validating forms are scupered as the checkboxes all

: have the same name.



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



Message #3 by Joe Ingle <Joe@k...> on Wed, 21 Nov 2001 09:33:07 -0000
Hi Ken



Sorry, I didn't explain clearly enough what I wanted to achieve. Counting

the checkboxes has solved my problem. I basically needed to check that at

least one of the boxes was checked, if none were checked redirect back to

the page with an error.



Thanks anyway, problem solved.



Joe



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

From: Ken Schaefer [mailto:ken@a...]

Sent: Wednesday, November 21, 2001 01:48

To: ASP Web HowTo

Subject: [asp_web_howto] Re: Array Validation





Joe,



When one "validates" something you test something against a criteria,

returning either a True result (valid), or a False result (invalid).



You have an "array", and you want to "validate" it. Against what criteria?

Do you want to know whether it is an array? If so, then isArray() is all you

need - returns True or False.



If you want to check that there is at least one value in the array, you

could use Join() to get a comma delimited string, and then see if there are

any values using InStr() or similar.



If you want to know how many checkboxes are checked, you could do this:

If Request.Form("chkBoxName").Count = 0 then

    ' None where checked

Else

    ' 1 or more where checked

End If



Really, you need to provide what you are testing against, before we can tell

you how to do it.



Cheers

Ken



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

From: "Joe" <joe@k...>

Subject: [asp_web_howto] Array Validation





: Hi Folks

:

: Does anyone out there have a nifty way of validating and array?

:

: Basically I have an array built from a query. The array is of variable

: size, returning a set of checkboxes all named txtNote.

:

: The array is then passed over to another asp page. At this point I would

: like to check that at least 1 of the checkboxes has been checked.

:

: All my usual ways of validating forms are scupered as the checkboxes all

: have the same name.



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








$subst('Email.Unsub')


  Return to Index