Wednesday, April 3, 2013

Validating date in JavaScript


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!

Related Posts :



0 comments on "Validating date in JavaScript"

Add your comment. Please don't spam!
Subscribe in a Reader

Post a Comment