validation - indicate invalid field

N

Niclas

Hi,

How do I indicate what field fails a validation, usually you see a red star
next to the faild field on a form. Is this built in functionality in the
valdaition controls or shall I code this myself ?

Niclas
 
G

Guest

Use the Text property of the validator and set the display to dynamic, e.g.
<asp:RequiredFieldValidator ID="valTextBox1" runat="server"
ErrorMessage="You have to enter a text"
ControlToValidate="txtBox1" Text="*" Display="dynamic">
</asp:RequiredFieldValidator>

This will show a red "*" when the user tabs off the textbox without entring
any value.

The ErrorMessage property will then display the detailed message if you have
a ValidationSummary control defined on the form.

http://msdn.microsoft.com/library/d...ntrolsbasevalidatorclasserrormessagetopic.asp


A quote from the above link:

"Use the ErrorMessage property to specify the text to display in the
validation control when validation fails. This text is also included in the
ValidationSummary control, if one is placed on the Web page.

It is possible to display different text for the validation control and the
ValidationSummary control. Use the Text property to specify the text to
display in the validation control.

Note If the Text property is set, that text will override the text
specified in the ErrorMessage property and appear in the validation control.
However, the text specified by the ErrorMessage property always appears in
the ValidationSummary control."
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top