Skip to content

Commit 0f0bc98

Browse files
committed
Add time inputs
1 parent 07b16ac commit 0f0bc98

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

index.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
<input type="date" name="date" id="date">
1717
<label for="dateInput">Date Input:</label>
1818
<input type="text" name="dateInput" id="dateInput">
19+
<label for="time">Time:</label>
20+
<input type="time" name="time" id="time">
21+
<label for="timeInput">Time Input:</label>
22+
<input type="text" name="timeInput" id="timeInput">
1923
<input type="submit" value="Submit">
2024
</form>
2125
</body>

validate.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434
$dateInputErr = "Invalid date format";
3535
}
3636
}
37+
38+
if (empty($_POST["time"])) {
39+
$timeErr = "Time is required";
40+
} else {
41+
$time = htmlspecialchars($_POST["time"]);
42+
$timeTimestamp = strtotime($timeInput);
43+
if ($timeTimestamp === false) {
44+
$timeInputErr = "Invalid time format";
45+
}
46+
}
3747
}
3848
echo "<p>Name: $name</p>";
3949
if ($nameErr) {

0 commit comments

Comments
 (0)