Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Valid Date Checking does not work in IE8 (and Firefox)
    primarykey
    data
    text
    <p>I have tried two popular answers from <a href="https://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript">Detecting an &quot;invalid date&quot; Date instance in JavaScript</a> for checking valid dates. I tested both of them in IE8 – Unfortunately both are disappointing. See it here <a href="http://jsfiddle.net/Lijo/uzSU6/2/" rel="nofollow noreferrer">http://jsfiddle.net/Lijo/uzSU6/2/</a> </p> <p>Is there a better JavaScript code that will work in IE8 + Chrome + Firefox?</p> <p>Note: To my surprise, it doesn't work well in Firefox too...</p> <p><strong>CONDITION</strong></p> <p>The date format is expected to be US date format with slashes (/)</p> <p><img src="https://i.stack.imgur.com/eMP9S.jpg" alt="enter image description here"></p> <p><strong>CODE</strong></p> <pre><code>isValidDateCheck2('12/33/2012') ; isValidDateCheck1('12/12/2012') ; function isValidDateCheck1(d) { alert(Object.prototype.toString.call(d)); if ( Object.prototype.toString.call(d) !== "[object Date]" ) { alert('Not Valid'); } if(!isNaN(d.getTime())) { alert(d.getTime()); } } function isValidDateCheck2(d) { var timestamp=Date.parse(d); alert(timestamp); if (isNaN(timestamp)==false) { var date=new Date(timestamp); alert(date); } } </code></pre> <p><strong>EDIT</strong></p> <p>@mplungjan approach (first suggested) is listed in <a href="http://jsfiddle.net/Lijo/uzSU6/7/" rel="nofollow noreferrer">http://jsfiddle.net/Lijo/uzSU6/7/</a>. This was failed in IE8 for one scenario - <a href="http://jsfiddle.net/Lijo/uzSU6/12/" rel="nofollow noreferrer">http://jsfiddle.net/Lijo/uzSU6/12/</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload