-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContac .html
69 lines (62 loc) · 2.77 KB
/
Contac .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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Us - Gusau Crime Reporting System</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Contact Us</h1>
<p>If you have any questions, feedback, or need assistance, feel free to reach out to us using the form below. We’re here to help you.</p>
<form id="contactForm" onsubmit="return validateForm()">
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" name="name" placeholder="Your Name">
<span id="nameError" class="error-message">Please enter your name.</span>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" placeholder="Your Email">
<span id="emailError" class="error-message">Please enter a valid email.</span>
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea id="message" name="message" rows="5" placeholder="Your Message"></textarea>
<span id="messageError" class="error-message">Please enter your message.</span>
</div>
<button type="submit" class="submit-button">Submit</button>
</form>
</div>
<script>
function validateForm() {
// Clear any previous error messages
document.getElementById("nameError").style.display = "none";
document.getElementById("emailError").style.display = "none";
document.getElementById("messageError").style.display = "none";
let isValid = true;
// Validate name
const name = document.getElementById("name").value.trim();
if (name === "") {
document.getElementById("nameError").style.display = "block";
isValid = false;
}
// Validate email
const email = document.getElementById("email").value.trim();
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
if (email === "" || !emailPattern.test(email)) {
document.getElementById("emailError").style.display = "block";
isValid = false;
}
// Validate message
const message = document.getElementById("message").value.trim();
if (message === "") {
document.getElementById("messageError").style.display = "block";
isValid = false;
}
return isValid;
}
</script>
</body>
</html>