This commit is contained in:
2025-08-21 16:04:24 +05:45
parent 76bf4c0a18
commit 0307244399
16 changed files with 443 additions and 23 deletions

View File

@@ -66,8 +66,8 @@
</div>
<div class="clearfix"></div>
<div class="form-group col-md-4 col-sm-12 col-xs-12">
<input type="text" name="contact_no" placeholder="Contact No*" required="required">
<div class="form-group col-md-4 col-sm-12 col-xs-12 contact-us-form">
<input type="tel" class="phone-number" name="contact_no" placeholder="Contact No*" required="required">
</div>
<div class="form-group col-md-8 col-sm-12 col-xs-12">
@@ -95,3 +95,46 @@
</div>
</section>
@endsection
@push('js')
<script>
$(document).ready(function () {
$("form[action='{{ route('make-appointment') }}']").on("submit", function (e) {
e.preventDefault();
var form = $(this);
var url = form.attr("action");
// Remove previous error messages
form.find(".text-danger").remove();
$.ajax({
url: url,
type: "POST",
data: form.serialize(),
success: function (response) {
// Reset form
form[0].reset();
// Redirect to thank you page
window.location.href = "/thankyou";
},
error: function (xhr) {
if (xhr.status === 422) {
var errors = xhr.responseJSON.errors;
$.each(errors, function (key, value) {
var field = form.find("[name='" + key + "']");
var wrapper = field.closest(".form-group"); // keep error inside the form group
wrapper.append('<div class="text-danger mt-1">' + value[0] + '</div>');
});
} else {
// alert("Something went wrong, please try again later.");
toast.error("Something went wrong, please try again later.");
}
}
});
});
});
</script>
@endpush