Please allow me to ask one more question.
We have the following HTML:
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtspname" TabIndex="6" Text='<%# Eval("spname") %>' placeholder="Name...(e.g, ABC, Inc.)" runat="server" style="width:375px;" class="form-control align-left" AutoPostBack="true" OnTextChanged="txtspname_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="spDetails" ClientIDMode="Static" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="SpCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtspaddress" TabIndex="7" Text='<%# Eval("spaddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control align-left" AutoPostBack="true" OnTextChanged="txtspname_TextChanged"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
There are two textbox controls, one for user to enter name and the other, for user to enter address.
So far, we have a VB code that checks the two textboxes. If BOTH are blank, then the user is presented with an alert that tells user to either enter data into both boxes or check the NA checkbox.
The problem is right now, users can enter data into either name box or address box only and the records will submit.
We would like to modify the VB so that if user enters data into name box only or the address box only, user should be prevented from submitting the records and should receive a alert similar to the one used in the VB code below:
Dim namespouse As TextBox = TryCast(row.FindControl("txtspname"), TextBox)
Dim nmespouse As String = namespouse.Text
Dim addressspouse As TextBox = TryCast(row.FindControl("txtspaddress"), TextBox)
Dim addrspouse As String = addressspouse.Text
Dim ckb2 As CheckBox = TryCast(row.FindControl("spDetails"), CheckBox)
Dim checkc As Boolean = ckb2.Checked
If checkc = False AndAlso nmespouse = "" AndAlso addrspouse = "" OrElse nmespouse = "" OrElse addrspouse = "" Then
ClientScript.RegisterStartupScript([GetType](), "Confirm", "jAlert('Please enter name and address of spouse or check the checkbox if N/A!');", True)
Return
End If