CompareValidator and Todays Date
Posted on 2004-04-12
I am trying to compare a textbox field to todays date so that the user can not enter something less than today.
Dim static strToday as String = CStr(Today)
<asp:CompareValidator Runat=server ID= CompareValidator1 ErrorMessage="Date must be AFTER Today" ControlToValidate = "txtStartDate" ValueToCompare="strToday" Type=Date></asp:CompareValidator>
This gives error:
The value 'strToday' of the ValueToCompare property of 'CompareValidator1' cannot be converted to type 'Date'.
I am fairly sure it is because strToday = #4/12/2004# and the # need to be stripped off. Do I need to create a function to strip this off? There must be an easier way.