-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewappointment.html
More file actions
216 lines (185 loc) · 6.22 KB
/
newappointment.html
File metadata and controls
216 lines (185 loc) · 6.22 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Appointment | LabCare</title>
<link rel="shortcut icon" href="./images/lab image.jpg" type="image/x-icon" />
<style>
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f5f7fa;
}
.container {
max-width: 340px;
margin: 25px auto;
background: white;
padding: 1.2rem;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}
h1 {
text-align: center;
color: #007bff;
margin-bottom: 1.5rem;
font-size: 1.4rem;
}
label {
display: block;
margin-bottom: 0.3rem;
font-weight: 600;
font-size: 0.9rem;
}
input, select {
width: 100%;
padding: 0.6rem;
border-radius: 6px;
border: 1px solid #ccc;
margin-bottom: 1rem;
font-size: 0.9rem;
box-sizing: border-box;
transition: border-color 0.2s ease;
}
input.valid, select.valid {
border-color: #007bff;
}
input.error, select.error {
border-color: red;
}
.error-message {
color: red;
font-size: 0.7.5rem;
margin-top: -0.1rem;
margin-bottom: 0.1rem;
display: none;
}
button {
background-color: #007bff;
color: white;
padding: 0.6rem;
border: none;
width: 100%;
font-weight: bold;
border-radius: 6px;
cursor: pointer;
font-size: 0.95rem;
}
button:hover {
background-color: #0056b3;
}
.success-message {
color: green;
text-align: center;
margin-top: 1rem;
font-size: 0.9rem;
}
@media (max-width: 480px) {
.container {
margin: 20px;
padding: 1rem;
}
}
</style>
</head>
<body>
<div class="container">
<h1>Book Appointment</h1>
<form id="appointmentForm" novalidate>
<label for="name">Full Name</label>
<input type="text" id="name" />
<div class="error-message" id="nameError">Full Name is required (min 2 characters)</div>
<label for="email">Email</label>
<input type="email" id="email" />
<div class="error-message" id="emailError">Valid email is required</div>
<label for="date">Date</label>
<input type="date" id="date" />
<div class="error-message" id="dateError">Please select a date</div>
<label for="service">Service</label>
<select id="service">
<option value="">Select Service</option>
<option value="Blood Test">Blood Test</option>
<option value="X-Ray">X-Ray</option>
<option value="MRI">MRI</option>
<option value="COVID-19 Test">COVID-19 Test</option>
<option value="AIDS Test">AIDS Test</option>
<option value="Typhoid Test">Typhoid Test</option>
<option value="Hepatitis Test">Hepatitis Test</option>
<option value="Calcium Test">Calcium Test</option>
<option value="Vitamin D Test">Vitamin D Test</option>
<option value="Magnesium Test">Magnesium Test</option>
<option value="Thyroid (T3, TSH, T4) Test">Thyroid (T3, TSH, T4) Test</option>
<option value="Iron Test">Iron Test</option>
<option value="Urine Test">Urine Test</option>
<option value="RFT Test">RFT Test</option>
</select>
<div class="error-message" id="serviceError">Please select a service</div>
<label for="fee">Fee ($)</label>
<input type="number" id="fee" min="1" />
<div class="error-message" id="feeError">Fee must be at least $1</div>
<button type="submit">Submit</button>
</form>
<div class="success-message" id="successMessage"></div>
</div>
<script>
const form = document.getElementById('appointmentForm');
const successMessage = document.getElementById('successMessage');
const fields = [
{ id: 'name', validator: v => v.trim().length >= 2, errorId: 'nameError' },
{ id: 'email', validator: v => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v.trim()), errorId: 'emailError' },
{ id: 'date', validator: v => v !== '', errorId: 'dateError' },
{ id: 'service', validator: v => v !== '', errorId: 'serviceError' },
{ id: 'fee', validator: v => parseFloat(v) >= 1, errorId: 'feeError' },
];
function validateFields() {
let isValid = true;
fields.forEach(field => {
const input = document.getElementById(field.id);
const error = document.getElementById(field.errorId);
const value = input.value.trim();
if (!field.validator(value)) {
input.classList.remove('valid');
input.classList.add('error');
error.style.display = 'block';
isValid = false;
} else {
input.classList.remove('error');
input.classList.add('valid');
error.style.display = 'none';
}
});
return isValid;
}
form.addEventListener('submit', function (e) {
e.preventDefault();
successMessage.textContent = '';
if (!validateFields()) return;
const name = document.getElementById('name').value.trim();
const email = document.getElementById('email').value.trim();
const date = document.getElementById('date').value;
const service = document.getElementById('service').value;
const fee = parseFloat(document.getElementById('fee').value);
const user = JSON.parse(localStorage.getItem('user'));
const today = new Date().toISOString().split('T')[0];
if (user) {
if (date === today) {
user.dashboardData.appointmentsToday += 1;
}
user.dashboardData.revenue += fee;
user.dashboardData.recentActivity.unshift(
`New appointment by ${name} for ${service} on ${date}.`
);
localStorage.setItem('user', JSON.stringify(user));
}
form.reset();
fields.forEach(field => {
const input = document.getElementById(field.id);
const error = document.getElementById(field.errorId);
input.classList.remove('error', 'valid');
error.style.display = 'none';
});
successMessage.textContent = "Appointment submitted successfully!";
});
</script>
</body>
</html>