-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task5.html
173 lines (163 loc) · 7.72 KB
/
Task5.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- Include Bootstrap CSS and Font Awesome CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css">
</head>
<body>
<div class="container mt-5">
<form id="myForm">
<table class="m-5">
<tr>
<td>FirstName</td>
<td>
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-image-portrait"></i></span>
<input type="text" class="form-control" id="firstName" placeholder="First Name" required data-name="First Name">
</div>
<span id="firstNameWarning" class="text-danger"></span>
</div>
</td>
</tr>
<tr>
<td>
Last Name
</td>
<td>
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-image-portrait"></i></span>
<input type="text" class="form-control" id="lastName" placeholder="Last Name" required data-name="Last Name">
</div>
<span id="lastNameWarning" class="text-danger"></span>
</div>
</td>
</tr>
<tr>
<td>E-Mail</td>
<td>
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="far fa-envelope"></i></span>
<input type="email" class="form-control" id="email" placeholder="Email" required data-name="Email">
</div>
<span id="emailWarning" class="text-danger"></span>
</div>
</td>
</tr>
<tr>
<td>Phone #</td>
<td>
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-phone"></i></span>
<input type="tel" class="form-control" id="mobileNumber" placeholder="Mobile Number" required data-name="Mobile Number">
</div>
<span id="mobileNumberWarning" class="text-danger"></span>
</div>
</td>
</tr>
<tr>
<td>
Address
</td>
<td>
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-house"></i></span>
<input type="text" class="form-control" id="address" placeholder="Address" required data-name="Address">
</div>
<span id="addressWarning" class="text-danger"></span>
</div>
</td>
</tr>
<tr>
<td>City</td>
<td>
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-house"></i></span>
<input type="text" class="form-control" id="city" placeholder="City" required data-name="City">
</div>
<span id="cityWarning" class="text-danger"></span>
</div>
</td>
</tr>
<tr>
<td>State</td>
<td>
<div class="mb-3">
<div class="input-group">
<span class="input-group-text"><i class="fas fa-list"></i></span>
<select class="form-control" id="state" required data-name="State (India)">
<!-- Add your state options here -->
<option value="state1">State 1</option>
<option value="state2">State 2</option>
<!-- Add more states as needed -->
</select>
</div>
<span id="stateWarning" class="text-danger"></span>
</div>
</td>
</tr>
<tr>
<td>Doyou have hosting?</td>
<td >
<div class="mb-3">
<input type="radio" id="host" required value="Yes">
<label for="host">Yes</label> <br>
<input type="radio" id="host" required >
<label for="host">No</label>
</div>
</td>
</tr>
<tr>
<td>Project Description</td>
<td>
<div class="mb-3">
<textarea name="prodesc" id="Prodesc" cols="30" rows="5"></textarea>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<button type="button" class="btn btn-danger btn-block" onclick="validateForm()">Submit</button>
</td>
</tr>
</table>
</form>
</div>
<!-- Include Bootstrap JavaScript and other libraries -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm" crossorigin="anonymous"></script>
<script>
function validateForm() {
const form = document.getElementById("myForm");
const inputs = form.querySelectorAll("input[required], select[required]");
let isValid = true;
inputs.forEach(input => {
if (input.value.trim() === "") {
isValid = false;
input.classList.add("is-invalid");
const fieldName = input.getAttribute("data-name");
const warningId = input.id + "Warning";
document.getElementById(warningId).textContent = fieldName + " is required.";
} else {
input.classList.remove("is-invalid");
const warningId = input.id + "Warning";
document.getElementById(warningId).textContent = "";
}
});
if (isValid) {
form.submit();
}
}
</script>
</body>
</html>