Hallo,
hab eine kleine Verbesserung
if (strlen($_POST['montagvon']) > 0) {
$time = $_POST['montagvon'];
if( preg_match("/^(\d{1,2}):(\d{1,2})$/", $time, $matches) && ($matches[1] <= 24 && $matches[1] >= 0) && ($matches[2] <= 59 && $matches[2] >= 0) )
echo '';
else
$errors[] = 'Der Wert '.$_POST['montagvon'].' ist keine gültige Uhrzeit';
}
Nur ich frage mich warum ich das echo '';
benötige. Nehme ich das raus geht nichts mehr. Außerdem ist es möglich wenn eine falsche Eingabe vorhanden ist, den Wert von $_POST['montagvon']
zu löschen, dass im Feld
<input type="text" name="montagvon" id="montagvon" class="time_input" value="<?php echo $_POST['montagvon'];?>" >
nichts mehr steht? Getestet habe ich es so
if (strlen($_POST['montagvon']) > 0) {
$time = $_POST['montagvon'];
if( preg_match("/^(\d{1,2}):(\d{1,2})$/", $time, $matches) && ($matches[1] <= 24 && $matches[1] >= 0) && ($matches[2] <= 59 && $matches[2] >= 0) )
echo '';
else
$errors[] = 'Der Wert '.$_POST['montagvon'].' ist keine gültige Uhrzeit';
$_POST['montagvon'] = '';
}
leider ist dann auch die Eingabe weg sollte die Uhrzeit richtig sein.