Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tour Feebdback form submits without filling any information #1171 #1173

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions feed.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ <h2>Tour Feedback Form</h2>
placeholder="Name the tour you attended:"
id="event_name"
class="form-control"
required
/>
</div>
<div class="col-md-6">
Expand All @@ -50,6 +51,7 @@ <h2>Tour Feedback Form</h2>
placeholder="Tour Date:"
name="event_date"
id="event_date"
required
/>
</div>
</div>
Expand All @@ -62,6 +64,7 @@ <h2>Tour Feedback Form</h2>
id="FullName"
placeholder="Your Name"
class="form-control"
required
/>
</div>
<br />
Expand All @@ -73,6 +76,7 @@ <h2>Tour Feedback Form</h2>
placeholder="Email Id"
name="Email"
id="Email"
required
/>
</div>
</div>
Expand All @@ -83,21 +87,21 @@ <h3>What's your opinion about:</h3>
<div class="row mb-3">
<div class="col-md-12">
<label>Ease of navigation?</label>
<div class="d-flex flex-wrap" id="navigationEase"></div>
<div class="d-flex flex-wrap" id="navigationEase" required></div>
<p id="navigationEase-rating-text">Rating: 0</p>
</div>
</div>
<div class="row mb-3">
<div class="col-md-12">
<label>Booking process</label>
<div class="d-flex flex-wrap" id="bookingProcess"></div>
<div class="d-flex flex-wrap" id="bookingProcess" required></div>
<p id="bookingProcess-rating-text">Rating: 0</p>
</div>
</div>
<div class="row mb-3">
<div class="col-md-12">
<label>Accuracy of information provided</label>
<div class="d-flex flex-wrap" id="accuracyInformation"></div>
<div class="d-flex flex-wrap" id="accuracyInformation" required></div>
<p id="accuracyInformation-rating-text">Rating: 0</p>
</div>
</div>
Expand All @@ -108,22 +112,22 @@ <h3>How would you rate the following aspects?</h3>
<div class="row mb-3">
<div class="col-md-12">
<label>Payment options</label>
<div class="d-flex flex-wrap" id="paymentOptions"></div>
<div class="d-flex flex-wrap" id="paymentOptions" required></div>
<p id="paymentOptions-rating-text">Rating: 0</p>
</div>
</div>
<div class="row mb-3">
<div class="col-md-12">
<label>Security Measures</label>
<div class="d-flex flex-wrap" id="securityMeasures"></div>
<div class="d-flex flex-wrap" id="securityMeasures" required></div>
<p id="securityMeasures-rating-text">Rating: 0</p>
</div>
</div>

<div class="row mb-3">
<div class="col-md-12">
<label>Customer Support</label>
<div class="d-flex flex-wrap" id="customerSupport"></div>
<div class="d-flex flex-wrap" id="customerSupport" required></div>
<p id="customerSupport-rating-text">Rating: 0</p>
</div>
</div>
Expand Down Expand Up @@ -187,6 +191,17 @@ <h3>How would you rate the following aspects?</h3>
</a>
</div>
</form>
</div>
</div><script>
document.addEventListener("DOMContentLoaded", () => { //for date check and preventing future selection
// Get today's date in ISO format (YYYY-MM-DD)
const today = new Date().toISOString().split("T")[0];

// Set min attribute for all date inputs to today's date
const dateInputs = document.querySelectorAll('input[type="date"]');
dateInputs.forEach((input) => {
input.setAttribute("max", today);
});
});
</script>
</body>
</html>
22 changes: 21 additions & 1 deletion feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ document.addEventListener("DOMContentLoaded", function () {
const comments = document.getElementById("comments").value.trim();

// Check if the feedback is empty
if (comments === "") {
if (comments === "" || comments.length < 4) {
Swal.fire({
icon: "error",
title: "Oops...",
Expand Down Expand Up @@ -76,6 +76,26 @@ document.addEventListener("DOMContentLoaded", function () {
// Clear the feedback form after the user acknowledges the success modal
if (result.isConfirmed || result.isDismissed) {
form.reset();

// Reset star ratings
const ratingCategories = [
"navigationEase",
"bookingProcess",
"accuracyInformation",
"paymentOptions",
"securityMeasures",
"customerSupport",
"overallExperience",
];

ratingCategories.forEach((category) => {
const stars = document.querySelectorAll(`#${category} .star`);
stars.forEach((star) => {
star.classList.remove("checked");
});
const ratingText = document.getElementById(`${category}-rating-text`);
ratingText.textContent = `Rating: 0`;
});
}
});
});
Expand Down
Loading