Tuesday, June 3, 2008

Regex or Simple Code

I've seen a solution with an ASP.NET textbox to hold a date value, which was validated by a regular expression validator. The regular expression sure looked ugly with a 2-line long regular expression string.

I compared it with my solution, involving the user of a custom validation, that looks sweet and simple and is easy to maintain. I just used the DateTime.TryParse to set the IsValid property of the ServerValidateEventArgs argument.

Score one for the simple code!

No comments: