www.webdeveloper.com
Results 1 to 3 of 3

Thread: But it really is false

  1. #1
    Join Date
    Feb 2007
    Location
    England
    Posts
    8

    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:
            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; 02-22-2007 at 08:46 AM.

  2. #2
    Join Date
    Nov 2002
    Posts
    4,473
    Try this:
    Code:
    var startsecs = (document.getElementById('starthour').value * 60) + (document.getElementById('startminute').value * 1);
    var endsecs = (document.getElementById('endhour').value * 60) + (document.getElementById('endminute').value * 1);

  3. #3
    Join Date
    Feb 2007
    Location
    England
    Posts
    8
    Thanks a lot, problem solved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles