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

@@ -81,7 +81,7 @@
<div class="col-md-7 col-sm-6 col-xs-12 contact-form wow fadeInLeft" data-wow-delay="0ms"
data-wow-duration="1000ms">
<h2>Write in details</h2>
<form action="{{ route('contactUsMessage') }}" method="post">
<form id="contactForm" action="{{ route('contactUsMessage') }}" method="post">
@csrf
<div class="field-container clearfix">
<div class="form-group col-md-6 col-sm-12 col-xs-12">
@@ -97,8 +97,8 @@
@enderror
</div>
<div class="clearfix"></div>
<div class="form-group col-md-4 col-sm-12 col-xs-12">
<input type="text" name="phone" placeholder="Contact No*" required="required">
<div class="form-group col-md-4 col-sm-12 col-xs-12 contact-us-form">
<input type="text" class="phone-number" name="phone" placeholder="Contact No*" required="required">
@error('phone')
<div class="text-danger">{{ $message }}</div>
@enderror
@@ -136,3 +136,40 @@
</div>
</section>
@endsection
@push('js')
<script>
$(document).ready(function () {
$("#contactForm").on("submit", function (e) {
e.preventDefault();
var form = $(this);
var url = form.attr("action");
$.ajax({
url: url,
type: "POST",
data: form.serialize(),
success: function (response) {
form[0].reset();
window.location.href = "/thankyou";
},
error: function (xhr) {
// handle validation errors
if (xhr.status === 422) {
var errors = xhr.responseJSON.errors;
$(".text-danger").remove();
$.each(errors, function (key, value) {
$("[name='" + key + "']").after('<div class="text-danger">' + value[0] + "</div>");
});
} else {
alert("Something went wrong, please try again later.");
}
}
});
});
});
</script>
@endpush