from : 5/19/2011
to : 2011-05-19
I need it to raise an error when it finds that it cannot be real like 5/40/2011
etc.
How about Datejs an open source date library? Specifically:
http://code.google.com/p/datejs/wiki/APIDocumentation#parseExact
Date.parseExact("10/15/2004", "M/d/yyyy"); // The Date of 15-Oct-2004
Date.parse("15-Oct-2004", "d-MMM-yyyy"); // The Date of 15-Oct-2004
Date.parse("2004.10.15", "yyyy.MM.dd"); // The Date of 15-Oct-2004
Date.parseExact("10/15/2004", ["M/d/yyyy", "MMMM d, yyyy"]); // The Date of 15-Oct-2004
Return Value {Date} A Date object or null if the string cannot be converted into a Date.
or
http://code.google.com/p/datejs/wiki/APIDocumentation#validateDay
Date.validateDay(15, 2007, 1); // true, 15-Feb-2007
Date.validateDay(31, 2007, 10); // false, throws RangeError exception
Return Value {Boolean} true if within range, otherwise false.