SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have two fields, one's call $time1, one's call $time2, one is for hours, one is for minutes.

    To check for the correct input, I tried something like this:

    PHP Code:
    <?php

    //error checking, making sure the time is fill in properly
    if ( $time1>"24" || $time2>"59" || !ereg("[0-9]"$time1) || !ereg("[0-9]"$time1) )

    ?>
    First of all, is there a way to combine the two ereg so it's more compact? Also, the ereg does not stop people from entering negative numbers, I entered -5 and it worked fine. I have no idea why -5 is between 0-9, how can I stop people from doing that?

  2. #2
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why dont you just check if $time is <0???
    -Jordan

  3. #3
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I really should sleep more...


Bookmarks

Posting Permissions

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