How to Prevent Date Objects from Wrapping in IE
<p>I am writing a form validator that needs to combine the values of three fields/drop downs into a string and check that string to see if it is a valid date. Currently, I am doing this by combining the values into a string of the form mm/dd/yyyy and running that string through a comparison:</p>

<pre><code>// Value is a string like mm/dd/yyyy
var date = new Date(value);
if( !date_regex.test(value) || date.toString() == 'Invalid Date' ) {
    errors[element] = "Please provide a valid date";
}
</code></pre>

<p>This works fine in almost every case. In IE8, if the string is formed such that the month or day exceed the allowance for the given component, the date wraps them instead of marking the date as invalid. Examples:</p>

<pre><code>string: 03//2011
should be valid: no
is valid: no
Date.toString(): Invalid Date
correct: yes

string: 03/10/2011
should be valid: yes
is valid: yes
Date.toString(): Wed Mar 10 00:00:00 PST 2010
correct: yes

string: 03/40/2011
should be valid: no
is valid: yes
Date.toString(): Fri Apr 9 00:00:00 PST 2010
correct: no

string: 20/05/2011
should be valid: no
is valid: yes
Date.toString(): Fri Aug 5 00:00:00 PST 2010
correct: no
</code></pre>

<p>I've tried using Date.parse(value) and checking for NaN, but the date wraps the timestamp, too.</p>

<p>Any ideas on how to get IE to behave like the others?</p>

<p>Thanks much</p>
