简体   繁体   中英

Using RegularExpressionValidator to display asterisk on the next label

I have a request that I'm having difficulty working out… Once the 'Name' field is completed, the 5 labels below it should show a red asterisk

Form

I've added a RegularExpressionValidator which dynamically displays a red asterisk next the name label once the textbox is populated and tabbed, however this isn't what's required.

RegularExpressionValidator

<asp:RegularExpressionValidator runat="server" ControlToValidate="txtNewDos" Display="Dynamic" CssClass=" mandatory" ValidationExpression="^([\S\s]{0,1})$"></asp:RegularExpressionValidator>

ASP

<asp:Label runat="server" ID="lblNumCurStudentsDos" Text="Number of Current PGR students supervised"></asp:Label>

CSS

 .mandatory:after { content:' *'; color:red } 

Can anybody point me in the right direction as to how I can populate my CSS class next the 5 labels once the Name text box has been populated?

Placing the RegularExpressionValidator within each label <td> </td> works

<asp:RegularExpressionValidator runat="server" ControlToValidate="txtNewDos"
  Display="Dynamic" CssClass=" mandatory" ValidationExpression="^([\S\s]{0,1})$">
</asp:RegularExpressionValidator>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM