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!

Range Validator help for date validation

Status
Not open for further replies.

777axa

Technical User
Jul 30, 2002
48
US
Is there a way to set the min and max values in the Range Validator Control's properties using some of the built-in date functions.
I want min to be the today's date minus 50 years and max + 5 years.
I've tried typing <%=DateTime.Today%> into the properties but it gives an error.
Do i need to do some namespace import?

Also, is there something built in for checking non-leap year date errors like Feb 29?
Thank you.
 
You need to set the range validator's properties up in the page_load function if you want to do this

RangeValidator1.MinimumValue = Today.AddYears(-50).Date.ToString
RangeValidator1.MaximumValue = Today.AddYears(5).Date.ToString


Just make sure to set the type that your validating to a date.

As for the leap years the only way i know of to make sure of this is to use the calendar control and have the user select the dates from that. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top