Please help: Validating input from a combination of controls

P

Paul

Hi,

I'm developing a search facility for my web app. In order for the
search criteria to be valid the user must (a) enter some text in a
text box and check and least one checkbox (of which there are two)
and/or (b) select at least one item from a multiple select list box.
I've written the javascript to do the client side validation which
gets called on the click event of my search button. I'd like to
implement server side validation using the validation controls but am
not sure how to achieve this. Can the custom validation control be
used in this instance (i.e. to validate the input from multiple
controls). If so how?

Thanks,

Paul
 
P

Peter Blum

Yes, a CustomValidator can be built to describe the same logic on the server
side as on the client side. The trick is to avoid having it valid except
when this particular button is pressed. In this case, I'd avoid using the
Page.Validate() method which is automically called when the submit button's
CausesValidation = true. Instead, I'd hook up that button's Click event
handler and have it call Validate() on the CustomValidator. Set the button's
CausesValidation to false. If CustomValidator.IsValid is false, regenerate
the page without saving data.

This scenerio is a very common one that requires something called
"Validation Groups". ASP.NET 2.0 (Whidbey) will eventually have this
feature. In the meantime, I offer a commercial product that supports
Validation Groups and building the extensive logical case you describe
without coding. In fact, with my validators, it will generate the correct
JavaScript for you and it will work on IE, IE/Mac, Netscape 6+, Mozilla,
Opera 7 and Safari (whereas Microsoft's client-side validation is IE
specific.) My product is "Professional Validation And More". Learn more at
http://www.peterblum.com/vam/home.aspx.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top