Hi there,
Is this related to my book Beginning ASP.NET 3.5 in C# and
VB? If so, check out the discussion on page 302 and further to learn more about server- and client-side validation. Otherwise, you're better off posting these type of questions in a more generic ASP.NET 3.5 category:
http://p2p.wrox.com/asp-net-3-5-436/
I also don't see any JavaScript in your code at all, so I am not sure what you're trying to accomplish. Did you mistakenly say JavaScript when you meant server side C#? Or are you trying to replicate the server check at the client as well?
Maybe you're simply not checking for IsValid in the code that's working with the data? It would help if you'd provided more infiormation and posted the relevant pieces of code.
Also, if all you're doing is "throw", then the try/catch isn't really necessary. And instead of returning new DateTime() you might as well return DateTime.MinValue as that's what you're checking against.
Cheers,
Imar