Wednesday, April 3, 2013

Validating date in JavaScript

0 comments
People make me want to cry when they validate date using regular expression.

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

IMHO, its much simpler to use Date.Parse. For example,
var myDateString = '01-Aug-12​';
var isValidDate = !isNaN( Date.parse( myDateString ));
Happy Coding!

Read more...