S
simon
I have 2 <asp:textbox controls>:
<asp:textbox id="txt1" Runat="server" ></asp:textbox>
<asp:textbox id="txt2" Runat="server" ></asp:textbox>
User must insert the value either in txt1 OR in txt2, so one of them
shouldn't be empty.
So I use custom validator:
<asp:CustomValidator id="valPhone" Runat="server" ErrorMessage="You must
insert text1 or text2!"
ControlToValidate="txt2"
Display="Dynamic"></asp:CustomValidator>
AND server:
Private Sub valPhone_ServerValidate(ByVal source As Object, ByVal args As
System.Web.UI.WebControls.ServerValidateEventArgs) Handles
valPhone.ServerValidate
If txt1.Text = "" And txt2.Text = "" Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub
The server validation is fired only if there is some value in txt2 box.If
txt2.text is empty then server validation is not fired.
How can I solve this problem?
I would like also to include client validation.
Thank you,
Simon
<asp:textbox id="txt1" Runat="server" ></asp:textbox>
<asp:textbox id="txt2" Runat="server" ></asp:textbox>
User must insert the value either in txt1 OR in txt2, so one of them
shouldn't be empty.
So I use custom validator:
<asp:CustomValidator id="valPhone" Runat="server" ErrorMessage="You must
insert text1 or text2!"
ControlToValidate="txt2"
Display="Dynamic"></asp:CustomValidator>
AND server:
Private Sub valPhone_ServerValidate(ByVal source As Object, ByVal args As
System.Web.UI.WebControls.ServerValidateEventArgs) Handles
valPhone.ServerValidate
If txt1.Text = "" And txt2.Text = "" Then
args.IsValid = False
Else
args.IsValid = True
End If
End Sub
The server validation is fired only if there is some value in txt2 box.If
txt2.text is empty then server validation is not fired.
How can I solve this problem?
I would like also to include client validation.
Thank you,
Simon