Sourav Agarwal

Sourav Agarwal

  • 2.1k
  • 11
  • 4.2k

Add Minimum Date Validation in the MaskedEditValidator

Jun 1 2016 10:15 AM

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<br />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<br />e.g. mm/dd/yy" Display="None"></asp:MaskedEditValidator>

<asp:ValidatorCalloutExtender ID="vceTxtRERNextDue" runat="server" TargetControlID="mevTxtRERNextDue" Enabled="True"></asp:ValidatorCalloutExtender>

</td>

</tr>

</table>

</EditItemTemplate>

</asp:FormView>


Answers (3)