song2siren
Programmer
Hello
I just need to create a custom validator to check whether a control contains a value and, if it doesn't, change the style of div tag.
I tried this:
Sub surnameCheck_ServerValidate(sender as Object, e as ServerValidateEventArgs)
Dim strValue As String = e.Value
If not strValue is nothing then
e.IsValid = True
Else
e.IsValid = False
lblSurnameRow.Text = "<div class='row error'>"
End If
End Sub
With my controls like this:
<asp:Label ID="lblSurnameRow" runat="server"><div class="row"></asp:Label>
<span class="formElement"><asp:TextBox ID="frmSurname" onfocus="pviiW3Cbg(this,'#F4DFA9')" onblur="pviiW3Cbg(this,'#E5EFFF')" runat="server" /></span>
<asp:CustomValidator ControlToValidate="frmSurname" Display="Dynamic" runat="server" OnServerValidate="surnameCheck_ServerValidate" />
However, the form is submitted regardless of a value in frmSurname.
Hopefully, I'm missing something really simple, but any suggestions would be much appreciated.
Thanks
I just need to create a custom validator to check whether a control contains a value and, if it doesn't, change the style of div tag.
I tried this:
Sub surnameCheck_ServerValidate(sender as Object, e as ServerValidateEventArgs)
Dim strValue As String = e.Value
If not strValue is nothing then
e.IsValid = True
Else
e.IsValid = False
lblSurnameRow.Text = "<div class='row error'>"
End If
End Sub
With my controls like this:
<asp:Label ID="lblSurnameRow" runat="server"><div class="row"></asp:Label>
<span class="formElement"><asp:TextBox ID="frmSurname" onfocus="pviiW3Cbg(this,'#F4DFA9')" onblur="pviiW3Cbg(this,'#E5EFFF')" runat="server" /></span>
<asp:CustomValidator ControlToValidate="frmSurname" Display="Dynamic" runat="server" OnServerValidate="surnameCheck_ServerValidate" />
However, the form is submitted regardless of a value in frmSurname.
Hopefully, I'm missing something really simple, but any suggestions would be much appreciated.
Thanks