A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: time comparison

  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    43

    time comparison

    Not sure how to do this, I'm trying to validate a form, I've got all the form stuff working, but I have 2 fields: StartTime and EndTime, and they're comboboxes, with the same lists of about 20 entries : 7:00 AM to 5:00 PM in 30 minute intervals

    I'm trying to make sure that someone doesn't accidentally enter an EndTime that's before the StartTime, but I'm not exactly sure how to compare these two fields. (if EndTime < StartTime)

    Any help is greatly appreciated, thanks!

  2. #2
    Senior Member Computer Dork's Avatar
    Join Date
    Mar 2001
    Location
    St. Louis
    Posts
    1,026
    that's pretty much it -


    code:

    on(release){
    if (startTime >= endTime){
    dontSubmit();
    }else{
    submit();
    }
    }


  3. #3
    Member
    Join Date
    Jan 2004
    Posts
    43
    Duh? I'm an idiot. I don't know why it didn't work when I tried it, I think I may have had the operator backwards or something, but that works, thanks!!!

  4. #4
    Member
    Join Date
    Jan 2004
    Posts
    43
    Ok, now I realize why this only works half of the time. My comboboxes are filled with 41 items: starting with "7:00 AM" to "5:00 PM" in 15 minute intervals.

    So if I have the start time as "9:15 AM" and the end time as "7:15 AM", the validation works fine.

    But if I have the start time as "1:00 PM" and the end time as "7:15 AM" this will pass the validation, I assume because it's only looking at the "1" in 1:00 and thinking that 1 is less than the "7" in 7:15 AM. It's not taking into account the AM/PM.

    Is there a way to perhaps easily convert the time to 24 hour time? That way a comparison of 13:00 to 07:00 would also trigger the validation.

    Any help is greatly appreciated, thanks!!

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Im not sure of the 24 hour conversion...probably a better idea...btu cant you just do the same thing with yoru AM/PM then? (an IF statement?)

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center