Show an asterisk in a validation control, but in a brief error message

I need a way to show an asterisk with an invalid field and show a detailed message in the validation summary. However, setting β€œNONE” in the validation control suppresses any message that appears next to the validation field.

Is there any way to get such a hybrid function?

+3
source share
2 answers

Yes.

Set the text property to "*" and the ErrorMessage property for the error message. Sort of.

<asp:RequiredFieldValidator id="ValidateMyField" runat="server" text="*" 
errormessage="Hey, you must really specify something" 
controltovalidate="YourControl" />

For display, you can use display="Dynamic"to have * only take up space on the actual error.

+13
 <asp:ValidationSummary ID="valSummary" runat="server" />
<asp:CustomValidator ID="valUserNameTaken" runat="server" ErrorMessage="User name is already used in this system, please choose another.">*</asp:CustomValidator>
0

Source: https://habr.com/ru/post/1704287/


All Articles