Required Field Validator for multiple controls

S

Sam Collett

Is there a way of having a required field validator check to see if at
least one of a set of controls has information in it? I'm sure this can
somehow be done using a custom validator, but would like a validator
that worked like as a custom tag:

<MyValidator:MultipleRequiredFieldValidator
ControlsToValidate="TextBox1,TextBox2,TextBox3" ErrorMessage="You did
not fill in one of the required fields: TextBox1,TextBox2,TextBox3"
runat="server"/>

If not, how could this be done server-side?
 
A

Anders Norås [MCAD]

Is there a way of having a required field validator check to see if at
least one of a set of controls has information in it? I'm sure this can
somehow be done using a custom validator, but would like a validator
that worked like as a custom tag:

<MyValidator:MultipleRequiredFieldValidator
ControlsToValidate="TextBox1,TextBox2,TextBox3" ErrorMessage="You did
not fill in one of the required fields: TextBox1,TextBox2,TextBox3"
runat="server"/>

If not, how could this be done server-side?

The validator controls validate one control at the time. Hence the property
is named ControlToValidate and not ControlsToValidate. You can use the
ValidSummary control create a list of all the controls that are invalid.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 

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

Top