Given a string str, how could I check if it is in the dd/mm/yyyy format and contains a legal date ?
Some examples:
bla bla // false
14/09/2011 // true
09/14/2011 // false
14/9/2011 // false
1/09/2011 // false
14/09/11 // false
14.09.2011 // false
14/00/2011 // false
29/02/2011 // false
14/09/9999 // true
Edit: exact solution below
You could do something like this, but with a more accurate algorithm for day validation:
http://jsfiddle.net/aMWtj/
Date validation alg.: http://www.eee.hiflyers.co.uk/ProgPrac/DateValidation-algorithm.pdf
Exact solution: function that returns a parsed date or null, depending exactly on your requirements.
http://jsfiddle.net/aMWtj/2/
In case you need the function to return true/false and for a yyyy/mm/dd format