Skip to content

Commit 9bc1d95

Browse files
committed
Add more input fields
1 parent 0f0bc98 commit 9bc1d95

2 files changed

Lines changed: 113 additions & 3 deletions

File tree

index.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,39 @@
2020
<input type="time" name="time" id="time">
2121
<label for="timeInput">Time Input:</label>
2222
<input type="text" name="timeInput" id="timeInput">
23+
<label for="datetimeInput">Datetime Input:</label>
24+
<input type="datetime" name="datetimeInput" id="datetimeInput">
25+
<label for="datetimeLocalInput">Datetime Local Input:</label>
26+
<input type="datetime-local" name="datetimeLocalInput" id="datetimeLocalInput">
27+
<label for="month">Month:</label>
28+
<input type="month" name="month" id="month">
29+
<label for="week">Week:</label>
30+
<input type="week" name="week" id="week">
31+
<label for="number">Number:</label>
32+
<input type="number" name="number" id="number">
33+
<label for="range">Range:</label>
34+
<input type="range" name="range" id="range">
35+
<label for="color">Color:</label>
36+
<input type="color" name="color" id="color">
37+
<label for="search">Search:</label>
38+
<input type="search" name="search" id="search">
39+
<label for="tel">Tel:</label>
40+
<input type="tel" name="tel" id="tel">
41+
<label for="url">Url:</label>
42+
<input type="url" name="url" id="url">
43+
<label for="file">File:</label>
44+
<input type="file" name="file" id="file">
45+
<label for="checkbox">Checkbox:</label>
46+
<input type="checkbox" name="checkbox" id="checkbox">
47+
<label for="radio">Radio:</label>
48+
<input type="radio" name="radio" id="radio">
49+
<label for="select">Select:</label>
50+
<select name="select" id="select">
51+
<option value="option1">Option 1</option>
52+
<option value="option2">Option 2</option>
53+
</select>
54+
<label for="textarea">Textarea:</label>
55+
<textarea name="textarea" id="textarea"></textarea>
2356
<input type="submit" value="Submit">
2457
</form>
2558
</body>

validate.php

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<body>
99
<h1>Validation Result</h1>
1010
<?php
11-
$name = $email = $date = $dateInput = "";
12-
$nameErr = $emailErr = $dateErr = $dateInputErr = "";
11+
$name = $email = $date = $dateInput = $time = $timeInput = $datetimeInput = $datetimeLocalInput = $month = $week = $number = $range = $color = "";
12+
$nameErr = $emailErr = $dateErr = $dateInputErr = $timeErr = $timeInputErr = $datetimeInputErr = $datetimeLocalInputErr = $monthErr = $weekErr = $numberErr = $rangeErr = $colorErr = "";
1313
if ($_SERVER["REQUEST_METHOD"] == "POST") {
1414
if (empty($_POST["name"])) {
1515
$nameErr = "Name is required";
@@ -44,6 +44,48 @@
4444
$timeInputErr = "Invalid time format";
4545
}
4646
}
47+
48+
if (empty($_POST["datetimeInput"])) {
49+
$datetimeInputErr = "Datetime Input is required";
50+
} else {
51+
$datetimeInput = htmlspecialchars($_POST["datetimeInput"]);
52+
}
53+
54+
if (empty($_POST["datetimeLocalInput"])) {
55+
$datetimeLocalInputErr = "Datetime Local Input is required";
56+
} else {
57+
$datetimeLocalInput = htmlspecialchars($_POST["datetimeLocalInput"]);
58+
}
59+
60+
if (empty($_POST["month"])) {
61+
$monthErr = "Month is required";
62+
} else {
63+
$month = htmlspecialchars($_POST["month"]);
64+
}
65+
66+
if (empty($_POST["week"])) {
67+
$weekErr = "Week is required";
68+
} else {
69+
$week = htmlspecialchars($_POST["week"]);
70+
}
71+
72+
if (empty($_POST["number"])) {
73+
$numberErr = "Number is required";
74+
} else {
75+
$number = htmlspecialchars($_POST["number"]);
76+
}
77+
78+
if (empty($_POST["range"])) {
79+
$rangeErr = "Range is required";
80+
} else {
81+
$range = htmlspecialchars($_POST["range"]);
82+
}
83+
84+
if (empty($_POST["color"])) {
85+
$colorErr = "Color is required";
86+
} else {
87+
$color = htmlspecialchars($_POST["color"]);
88+
}
4789
}
4890
echo "<p>Name: $name</p>";
4991
if ($nameErr) {
@@ -61,7 +103,42 @@
61103
if ($dateInputErr) {
62104
echo "<p style='color:red;'>$dateInputErr</p>";
63105
}
64-
106+
echo "<p>Time: $time</p>";
107+
if ($timeErr) {
108+
echo "<p style='color:red;'>$timeErr</p>";
109+
}
110+
echo "<p>Time Input: $timeInput</p>";
111+
if ($timeInputErr) {
112+
echo "<p style='color:red;'>$timeInputErr</p>";
113+
}
114+
echo "<p>Datetime Input: $datetimeInput</p>";
115+
if ($datetimeInputErr) {
116+
echo "<p style='color:red;'>$datetimeInputErr</p>";
117+
}
118+
echo "<p>Datetime Local Input: $datetimeLocalInput</p>";
119+
if ($datetimeLocalInputErr) {
120+
echo "<p style='color:red;'>$datetimeLocalInputErr</p>";
121+
}
122+
echo "<p>Month: $month</p>";
123+
if ($monthErr) {
124+
echo "<p style='color:red;'>$monthErr</p>";
125+
}
126+
echo "<p>Week: $week</p>";
127+
if ($weekErr) {
128+
echo "<p style='color:red;'>$weekErr</p>";
129+
}
130+
echo "<p>Number: $number</p>";
131+
if ($numberErr) {
132+
echo "<p style='color:red;'>$numberErr</p>";
133+
}
134+
echo "<p>Range: $range</p>";
135+
if ($rangeErr) {
136+
echo "<p style='color:red;'>$rangeErr</p>";
137+
}
138+
echo "<p>Color: $color</p>";
139+
if ($colorErr) {
140+
echo "<p style='color:red;'>$colorErr</p>";
141+
}
65142
?>
66143
</body>
67144

0 commit comments

Comments
 (0)