I am working on ASP.NET Web Forms and need your guidance with the below problem.
In the below Form View, I have two textbox that accepts dates i.e. RER Filed & Next RER Due dates. I want to add a validation criteria to the Next RER Due field that its values should always be greater than RER Filed Field.
Below is the UI of the Form:
Below is the code of the above form:
<asp:FormView ID="FormView10" runat="server">
<EditItemTemplate>
<table>
<tr>
<td>RER Filed:td>
<td>
<asp:TextBox ID="txtRERFiled" name="txtRERFiled" runat="server" Text='<%# Bind("RERFiled", "{0:MM/dd/yy}") %>'>asp:TextBox>
<asp:MaskedEditExtender ID="meTxtRERFiled" runat="server" TargetControlID="txtRERFiled" Mask="99/99/99" MaskType="Date">asp:MaskedEditExtender>
<asp:MaskedEditValidator ID="mevTxtRERFiled" runat="server" ValidationExpression="^[0-9]{1,2}/[0-9]{1,2}/[0-9]{2}$" ControlExtender="meTxtRERFiled" ControlToValidate="txtRERFiled" ValidationGroup="pan10" InvalidValueMessage="Enter valid date
e.g. mm/dd/yy" Display="None">asp:MaskedEditValidator>
<asp:ValidatorCalloutExtender ID="vceTxtRERFiled" runat="server" TargetControlID="mevTxtRERFiled" Enabled="True">asp:ValidatorCalloutExtender>
td>
tr>
<tr>
<td>Next RER Due:td>
<td>
<asp:TextBox ID="txtRERNextDue" runat="server" name="txtRERNextDue" Text='<%# Bind("RERNextDue", "{0:MM/dd/yy}") %>'>asp:TextBox>
<asp:MaskedEditExtender ID="meTxtRERNextDue" runat="server" TargetControlID="txtRERNextDue" Mask="99/99/99" MaskType="Date">asp:MaskedEditExtender>
<asp:MaskedEditValidator ID="mevTxtRERNextDue" runat="server" ValidationExpression="^[0-9]{1,2}/[0-9]{1,2}/[0-9]{2}$" ControlExtender="meTxtRERNextDue" ControlToValidate="txtRERNextDue" ValidationGroup="pan10" InvalidValueMessage="Enter valid date
e.g. mm/dd/yy" Display="None">asp:MaskedEditValidator>
<asp:ValidatorCalloutExtender ID="vceTxtRERNextDue" runat="server" TargetControlID="mevTxtRERNextDue" Enabled="True">asp:ValidatorCalloutExtender>
td>
tr>
EditItemTemplate>
asp:FormView>
ali tuncerPosted Jun 2, 2016, 1:54 AM
I haven't used those ajax extensions before, I would either use CompareValidator or do validation on server side, when user submits data..
Sourav AgarwalPosted Jun 1, 2016, 9:59 PM
I tried using the CompareValiator to handle this but the error message displayed is not in Ajax popup format rather it displays label next to the end date textbox and due to limited space in the form I want to display validation message as popup.
I have 2 date fields - 1st one is 'start date' and 2nd one is 'end date'. I want to set the MaskedEditValidator for the end date so that the minimum value property is the date from the 'start date' field. So this way, the user can't enter a date in the 'end date' field that is earlier than what is in the 'start date' field.
<td>
<asp:TextBox ID="txtRERNextDue" runat="server" name="txtRERNextDue" Text='<%# Bind("RERNextDue", "{0:MM/dd/yy}") %>'>asp:TextBox>
<asp:MaskedEditExtender ID="meTxtRERNextDue" runat="server" TargetControlID="txtRERNextDue" Mask="99/99/99" MaskType="Date">asp:MaskedEditExtender>
<asp:MaskedEditValidator ID="mevTxtRERNextDue" OnMaskedEditServerValidator="mevTxtRERNextDue_MaskedEditServerValidator" runat="server" ValidationExpression="^[0-9]{1,2}/[0-9]{1,2}/[0-9]{2}$" ControlExtender="meTxtRERNextDue" ControlToValidate="txtRERNextDue" ValidationGroup="pan10" InvalidValueMessage="Enter valid date
e.g. mm/dd/yy" Display="Dynamic">asp:MaskedEditValidator>
<%-- --%>
<asp:ValidatorCalloutExtender ID="vceTxtRERNextDue" runat="server" TargetControlID="mevTxtRERNextDue" Enabled="True">asp:ValidatorCalloutExtender>
td>
ali tuncerPosted Jun 1, 2016, 9:45 PM
useCompareValidator control