Sameer Khan

Sameer Khan

  • NA
  • 100
  • 10.9k

How to check dates

Jan 28 2016 5:27 AM
How to check date should not be greater than today date using compare field validator i:e Client side validation in asp .net
 
I have used this
<asp:comparevalidator ID="Comparevalidator2" runat="server" errormessage="The date must be greater than today"
controltovalidate="txtRegDate" type="Date" Operator="GreaterThan"
valuetocompare='<%= DateTime.Now.ToShortDateString() %>' />
 
Getting Error
 
The value '<%= DateTime.Now.ToShortDateString() %>' of the ValueToCompare property of 'Comparevalidator2' cannot be converted to type 'Date'. 

Answers (4)