Possible Duplicate:
Compare 2 dates with JavaScript
i have this code on javascript
function calculate() {
var departing = document.getElementById('tickets_expiry_date_departing').value;
var returning = document.getElementById('tickets_expiry_date_returning').value;
if (returning > departing){ alert("Error"); } else { return true; }
}
then i call this function on
<input
class="txtFieldDate"
name="tickets_expiry_date_returning"
id="tickets_expiry_date_returning"
value="<?php echo $_POST["tickets_expiry_date_returning"]; ?>"
readonly="readonly"
onChange="calculate();"/>
When the element with id tickets_expiry_date_returning
has a value that I consider being less than the value of the element with id tickets_expiry_date_departing
I should get an alert displaying the error but I don't. Why?