The /
has a special meaning in a date format string. It means: "replace me with your curent culture's date separator". In germany for example it is .
.
The "/" custom format specifier represents the date separator, which is used to differentiate years, months, and days. The appropriate localized date separator is retrieved from the
DateTimeFormatInfoDateSeparator
property of the current or specified culture. ...
I think the only way is using a CustomValidator
to check this format. Then you can parse the date in this way(on serverside):
DateTime dt;
if(DateTime.TryParseExact(txtDate, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
{
// now there is a valid date in dt
}
Notice the CultureInfo.InvariantCulture
which i have used to enforce the /
as actual date separator.