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?