Home > .Net > How to use CompareValidator for date to be greater than today

How to use CompareValidator for date to be greater than today

<asp:CompareValidator ID=”cvExpDate” runat=”server” ControlToValidate=”txtExpDate” ErrorMessage=”Expire date should be greater than todays date” Operator=”GreaterThan” Type=”Date” ValidationGroup=”VG2″ ValueToCompare=”<%= DateTime.Today.ToShortString(); %>”>*</asp:CompareValidator>

On Page Load

cvExpDate.ValueToCompare = DateTime.Now.ToShortDateString();

Comments are closed.

TOP