Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This might be a little cleaner version, also note that you should always use a radix when using parseInt.</p> <pre><code>window.addEvent('domready', function() { // Create a Date object set to midnight on today's date var today = new Date((new Date()).setHours(0, 0, 0, 0)), input = $('datum').getValue(), dateArray = input.split('/'), // Always specify a radix with parseInt(), setting the radix to 10 ensures that // the number is interpreted as a decimal. It is particularly important with // dates, if the user had entered '09' for the month and you don't use a // radix '09' is interpreted as an octal number and parseInt would return 0, not 9! userMonth = parseInt(dateArray[1], 10) - 1, // Create a Date object set to midnight on the day the user specified userDate = new Date(dateArray[2], userMonth, dateArray[0], 0, 0, 0, 0); // Convert date objects to milliseconds and compare if(userDate.getTime() &gt; today.getTime()) { alert(today+'\n'+userDate); } }); </code></pre> <p>Checkout the MDC <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt" rel="nofollow noreferrer">parseInt</a> page for more information about the radix.</p> <p><a href="http://www.jslint.com/" rel="nofollow noreferrer">JSLint</a> is a great tool for catching things like a missing radix and many other things that can cause obscure and hard to debug errors. It forces you to use better coding standards so you avoid future headaches. I use it on every JavaScript project I code.</p>
 

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