Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple ASP validation question

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
GU
Hi everyone,

I've never been good at validation, but this is the situation:

I've got a series of (26) buttons in an ASP 3.0 page, and the form can be submitted with none checked, but only a maximum of (15) can ever be checked. How would I validate against this?

Thanks!
 
first, since you mention them being checked, i assume you mean check-boxes and not buttons?

if that's the case, and assuming that these check boxes all share the same name, then the value returned will be a comma-delimited list as a single string. you could use the "split" function to create and array and check for the "ubound" of the array. that'd tell you how many options were selected. for example...

Code:
aryValues = split(request("chkboxes"),",")
if ubound(aryValue) > 14 then
 'code for too many options selected
else
 'code for data valid
end if

another angle would be to create a function that'd count the number of commas in the return value plus 1.

glenn
 
Thanks for the feedback. This is about what I'm doing - using checkboxes - you were right, but each having different NAME attribiute values.

Any other ideas?
 
I would suggest keeping all checkboxes one name.. and if you must know what the value represents for that checkbox then name the checkbox value what it is... if that makes sence.
star.gif
if I helped. [wink]
s_vzio.gif
 
oh an gaca, a simple way to get count of checkboxes checked is to do this..

Response.Write(Request.Form("chkboxes").count)
star.gif
if I helped. [wink]
s_vzio.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top