Suppose the user enters 06/27/2010 in the text field and submits the form.
The default model binder runs and tries to bind what the user entered to your model. The
BirthDateproperty is of typeDateTimeand as you know this type contains an hour part. So nowBirthDate = 6/27/2010 12:00:00 AMValidation kicks in next. The
BirthDateproperty is decorated with theRegularExpressionattribute so theIsValidmethod is called with the string value of6/27/2010 12:00:00 AMwhich fails against your pattern.The corresponding error message is shown to the user.
So the usage of this regular expression attribute is questionable. RegularExpressionAttribute works fine with string properties though.
If the user enters an invalid date the model binder will protest anyway much before the validation happens. It will also check for invalid days and months which your regular expression doesn't.