But it really is false

This is a discussion on "But it really is false" within the JavaScript Forum section. This forum, and the thread "But it really is false are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 22nd, 2007, 11:19
Junior Member
Join Date: Feb 2006
Location: England
Age: 20
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Echilon Send a message via MSN to Echilon
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

  #2 (permalink)  
Old Feb 26th, 2007, 22:10
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: But it really is false

Are you quite literally entering '12:00' and '17:00' because if you are, these will not evaluate to numbers?
Reply With Quote
Reply

Tags
if statement

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem with onsubmit="some_function();return false;" LumberJake JavaScript Forum 3 Mar 31st, 2008 15:00


All times are GMT. The time now is 04:28.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43