changes
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user