Display message when RequiredFieldValidator fired

C

Christian Ista

Hello,

I have a form with 5 textbox for each one a RequiredFieldValidator I show
(*) if the field is missing when I post the form.

I'd like when a least one of theses RequiredFieldValidator fired display an
another message (other then ErrorMessage). Is there a way to do that ?

Thanks,
 
R

Ray Costanzo [MVP]

I suggest you display the asterisk next to all the required fields to begin
with in order to "pre-indicate" which fields are required. That's common
practice these days.

Ray at work
 
C

Christian Ista

Which is it, you want an asterisk or a message, it can't be both.

That's the point, I'd like both.

An asterisk is displayed next to the field and I'd like an another comment
in an another location.

Thanks,
 
C

Curt_C [MVP]

Set the text (between the <> and </>) to * and the Error message to "blah".
Then drop on the summary and on the validator set the Display=Static
 
J

Johann MacDonagh

So, you'd like to have an * next to the textbox, but a more helpful error
message somewhere else? That can be accomplished.

The RequiredFieldValidator (as well as the other Validation controls) have
two properties you should be interested in. The first is the ErrorMessage
property, and the second is the Text property. Set the ErrorMessage property
to "This field is required", and the Text property to "*". Then, add a
ValidationSummary control to the top of your form.

If validation errors occur, the Text property ("*") will be the one
displayed next to the TextBox, while the ErrorMessage property will be the
one displayed in the ValidationSummary control.

Hope this helps,
Johann MacDonagh
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top