Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date validation using RangeValidator 1

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
US
Hi:

I am trying to check that the date entered in a texbox is less than current date. I ensure that the date entered is valid using a compareValidator's dataTypeCheck property.

RangeValidator properties that I have set:

ControlToValidate = txtCheck
DataType = Date

In Page_load
rangeValidator1.MaxValue = Now.Date
rangeValidator1.MinValue = DateTime.MinValue.Date

I get an error saying MinValue 12:00:00 AM is not of type Date?????

Thanks
 
What is the minimum value that you want in the date field.

What your doing is trying to put a Time into the Date only type. DateTime.MinValue represents the smallest value that DateTime accepts. You need to set the rangeValidator.MinValue to a actuall date. Just put something like this there.

Now.AddYears(-10) to set the minimum accepted date to 10 years ago. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
np glad to help That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Hi:

Why do I have type the code for Maximum and Minimum value under Page_load()

Why can't I just type it in the properties window. When I do, I get an error saying MaximumValue Now.Date cannot be converted into type Date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top