WatermarkText="Enter the Date of Birth (dd/mm/yyyy)" />
And below is the CSS style that’s used with this watermark extender :
All looks good now and the user is happy the way Calendar pops up, choosing the date and also the fact that he can type in the date in the textbox in the desired format. Now comes the problem - Date Validation! - How are we going to validate the entered date? - I had to validate that the date entered is not more than today’s date.
There are two ways to do it :
2) Using RangeValidators for our textbox
var dt = new Date();
if(sender._selectedDate > dt)
Since we use a TextBox control to display our date once we choose from the calendar or to manually input the date, RangeValidators can be used to check whether the date is within a given range (minimum & maximum). Below is the code for RangeValidator :
ErrorMessage="*Please enter proper date"
Type="Date" Display="Dynamic" />
And in your page load event we can set our maximum and minimum date values :
= new DateTime(1600, 01, 01).ToString("dd/MM/yyyy");
With these two methods you can easily validate the date. And yes, using both would sometimes lead you to race conditions where choosing a date from the cale
see detail on this link