Custom error UI using requiredfieldvalidator assistance needed
Allow me to thank you in advance.
I'm presently using a standard asp.net control to validate a (Name) text field. As you can see by the code, I have moved the asterisk to the left of the textbox label (rather than put it next to the text box). What I would like to do it show the asp.net error "*" in place of the "<span class="required-asterisk">*</span>"
So if the user has no error they will see the <span class="required-asterisk">*</span> which is blue for example. However, if they have an error the blue "*" will be replaced by the asp.net default "*".
I would use the CustomValitator control. That way you can use an if statement to determine whether valid input was entered. Something like this may suffice.
sub ValidateField(Sender As Object, Args As ServerValidateEventArgs)
If Args.Value = Nothing Then
ErrMessage.Style("color") = "Red"
Args.IsValid = False
ErrMessage.Style("color") = "Blue"
Args.IsValid = True
<asp:CustomValidator runat="server" id="custVal_Name"
<span id="ErrMessage" style="color:blue;" runat="server">*</span>