I have two ASP.NET text-boxes
Textbox 1 Textbox 2
if a user inputs anything in textbox 1 I want to make input into textbox 2 required. What would be the best method of accomplishing this?
CompareValidator? RequiredValidator? CustomValidator?
Here's my code:
<div class="MHStransactionDateFrom">
<asp:Label ID="lblMHSTransactionDateFrom" runat="server" Text="Transaction Date From" Width="120"></asp:Label>
<asp:TextBox ID="ddlMHSTransactonDateFrom" runat="server" Height="10px" Width="100px" CssClass="small date"></asp:TextBox>
<div class="MHStransactionDateTo">
<asp:Label ID="lblMHSTransactionDateTo" runat="server" Text="Transaction Date To" style="font-size: 1.2em; color: #FFF;" Width="200"></asp:Label>
<asp:TextBox ID="ddlMHSTransactionDateTo" runat="server" Height="10px" Width="100px" CssClass="small date"></asp:TextBox>
</div>
In my opinion the perfect choice is relative to what you want to do, if the second textbox must have the same data as the first one, you should use the CompareValidtor. if the second data is required only and not needed to be the same as the first one, here you should use the RequiredValidator