Oh boy! That suggestion actually is much harder than using a validator.
Use the RangeValidator. It ignores blank fields automatically. It only
checks for errors when there is some text. Set Type=Date and your minimum
and maximum dates in the Minimum and Maximum properties.
Note that this will not report an error if the date entered is an illegal
format.
For that, use CompareValidator, Operator=DataTypeCheck, Type=Date.
Here are several ways to enhance your user interface:
1. You can combine the logic of several validators into one using the
MultiConditionValidator, part of my Professional Validation And More
product. (
http://www.peterblum.com/vam/home.aspx) It includes 22 validators
and greatly expands what you can do with validators. You can learn about the
limitations of Microsofts validators here:
http://www.peterblum.com/vam/valmain.aspx to use as you design your site.
2. There are many really nice date textboxes with popup calendars available
from third parties. They are listed at the
www.asp.net Control Gallery,
www.123aspx.com, and
www.411asp.net. Mine is Peter's Date Package
(
http://www.peterblum.com/datecontrols/home.aspx). It includes validators,
time entry, and stand-alone calendar that doesn't require post backs.
--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx