Generally speaking, in this day and age you shouldn’t need to roll your own javascript-based date validation when using ASP.NET MVC. DataAnnotations attributes on your view model properties should allow you to define the validation criteria you need. If you then need the validation to occur client-side you can then use the jquery.validate.unobtrusive.js library in collaboration with the Globalize.js fix described here (hint: not the response marked as the answer, as that one is — quite simply — stupid).

However, sometimes you might find a weird scenario where you can’t do the above, and are looking for a nice way to parse/validate a date string into a date. In my case I was dealing with the dd/mm/yyyy format and wanted to either return the date when valid, or null when invalid. It’s slightly convoluted, but works well: