Validating a Date!
-
Is it better to split a string with clear instructions or use Regex with Clear Instructions?
-
Is it better to split a string with clear instructions or use Regex with Clear Instructions?
-
Is it better to split a string with clear instructions or use Regex with Clear Instructions?
On the client side, Moment.js[^] or one of the many javascript date pickers would be the best option. On the server side, it depends which framework / language you're using. For .NET,
DateTime.TryParse
is the way to go, as Mika suggested. Other frameworks will probably have something very similar. If you try to re-invent date validation using string manipulation, you'll either get it wrong, or drive yourself mad trying. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Is it better to split a string with clear instructions or use Regex with Clear Instructions?
Hi Marcus, Follow this code to parse date and time. http://www.dotnetperls.com/datetime-parse[^]