Recently i have requirement to validate sign up age +18. I have search many sites to how it will calculate age on date. I found simple RangeValidator to accomplish this.
Now, in back end set RangeValidator minimum date and maximum date. To set it use following
rvDOB.MinimumValue = DateTime.Today.AddYears(-60).ToString("MM/dd/yyyy"); rvDOB.MaximumValue = DateTime.Today.AddYears(-18).ToString("MM/dd/yyyy");
You can set your years in AddYears as per your requirement. Hope it will help you!!!