View Single Post
  #1 (permalink)  
Old Feb 22nd, 2007, 11:19
Echilon Echilon is offline
Junior Member
Join Date: Feb 2006
Location: England
Age: 20
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
But it really is false

I have a validation function which compares two values, startsecs and endsecs. If startsecs is greater than endsecs, an error should be displayed, but it's not working because the if statement is evaluating as true, when it should be false.

You can see this by going to link removed, uncheck the box that says 'this event last all day', then enter 12:00 as the start time and 17:00 as the end time, and click save. Evevn in the error that's displayed, the second value is greater than the first, so it should evaluate as false.

The function can be seen at link removed on line 223.
Code: Select all
        var startsecs = (document.getElementById('starthour').value * 60) + document.getElementById('startminute').value;
        var endsecs = (document.getElementById('endhour').value * 60) + document.getElementById('endminute').value;
        if(startsecs > endsecs) {
            document.getElementById('error_end').innerHTML = 'End time must be after start time:'+endsecs+'::'+startsecs;
            document.getElementById('error_end').style.display = 'block';
            valid = false;
        }

Last edited by Echilon; Feb 22nd, 2007 at 13:45. Reason: Links removed
Reply With Quote