Validating entry in one of the fields

D

danavni

I have a form where the user need to fill some fields. some of these
fields are address fields (street, city, state, zip)
i want to validate that atleast one of these fields if filled with
data. then problem is that the CustomValidator control will not check
empty fields and the RequiredFieldValidator control can not check
multiple controls.

How do i do this?

Thanks
 
P

Peter Blum

There are two solutions.

1. The CustomValidator, as you have indicated. To avoid its requirement that
the field is not blank, do NOT assign anything to ControlToValidate. It will
fire on submit only.

2. If you think that your validation will require using the CustomValidator
frequently, my Professional Validation And More
(http://www.peterblum.com/vam/home.aspx) helps avoid custom coding. It has
22 validators. One is the MultiConditionValidator, which you use to combine
other validator's rules within a boolean condition. In your case, you need
the boolean condition of "Street is Required OR City is Required OR State
is Required OR Zip is Required). You will do all of this within the design
mode Properties Editor and it will even support client-side validation. My
client-side validation works on many more browsers than Microsoft's
validators too.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

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,888
Messages
2,569,964
Members
46,293
Latest member
BonnieHamb

Latest Threads

Top