-
Notifications
You must be signed in to change notification settings - Fork 0
/
Contact.html
157 lines (147 loc) · 5.48 KB
/
Contact.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact us</title>
<script src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0; /* Adding a light background color */
}
h3 {
color: forestgreen;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
border: 5px solid forestgreen;
border-radius: 15px;
background-color: white; /* Adding a white background color */
}
.btn {
display: inline-block;
padding: 10px 20px;
background-color: seagreen;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.radio-group {
display: flex;
align-items: center;
}
.radio-group label {
margin-right: 10px;
}
#output {
display: none;
}
#warning {
color: red;
}
/* Responsive Styles */
@media screen and (max-width: 768px) {
.container {
max-width: 90%; /* Adjusting the container width for smaller screens */
padding: 10px; /* Reducing padding for smaller screens */
}
}
</style>
</head>
<body>
<div class="container">
<h2>Contact Us</h2>
<form id="contactForm">
<div class="form-group">
<label for="full_name">Full Name *</label>
<input type="text" id="full_name" name="full_name" required>
</div>
<div class="form-group">
<label for="number">Number *</label>
<input type="tel" id="number" name="number" required>
</div>
<div class="form-group">
<label for="email">Email *</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="message">Message *</label>
<textarea id="message" name="message" required></textarea>
</div>
<!-- Hidden input field to capture the timestamp -->
<input type="hidden" id="timestamp" name="timestamp">
<button type="submit">Submit</button>
</form>
<!-- Display the submission timestamp here -->
<p id="submittedTimestamp"></p>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<script>
// Function to handle form submission
function SubForm() {
var timestamp = new Date().toISOString(); // Get the current timestamp in ISO format
// Add 5 hours and 30 minutes to the timestamp
var newTimestamp = new Date(new Date(timestamp).getTime() + 5 * 60 * 60 * 1000 + 30 * 60 * 1000);
var formattedTimestamp = newTimestamp.toISOString().replace("T", " ").split(".")[0]; // Format the timestamp
$("#timestamp").val(formattedTimestamp); // Set the value of the hidden input field
var formData = $("#contactForm").serializeArray();
// Check if all required fields are filled
var allFieldsFilled = true;
formData.forEach(function (field) {
if (field.value.trim() === '') {
allFieldsFilled = false;
}
});
if (!allFieldsFilled) {
alert("Please fill in all the required fields.");
return;
}
$.ajax({
url: "https://api.apispreadsheets.com/data/joCiWyHHbwPFltEL/",
type: "post",
data: formData,
success: function () {
alert("Form Data Submitted :)");
displayTimestamp(formattedTimestamp); // Display the timestamp
},
error: function () {
alert("There was an error :(");
}
});
}
// Function to display the submission timestamp
function displayTimestamp(timestamp) {
$("#submittedTimestamp").text("Form Submitted at: " + timestamp);
}
// Attach the SubForm function to the form's submit event
$("#contactForm").on("submit", function (event) {
event.preventDefault(); // Prevent the form from submitting normally
SubForm(); // Call the SubForm function to handle the submission
});
</script>
</body>
</html>