Hi,
I’m trying to make this code work but form.hide() doesn’t work as it should…
Maybe some of you have already done this and can help me with this issue which I can’t figure out by myself at all just stuck.
This is my JS
$(document).on("submit","af_complete", "form", function () {
var e = $(this),
t = !1;
return (
e.find("input").removeClass("error"),
e.find("input").parent().removeClass("error"),
e.find('[name="phone"]').each(function () {
"" == $(this).val() && ($(this).addClass("error"), $(this).parent().addClass("error"), (t = !0));
}),
t ||
$.ajax({ url: "action.php", type: "POST", dataType: "json", data: e.serialize() })
.done(function (e) {
$.fancybox.close("all"),form.hide(),
$.fancybox.open({ src: "#thanks" }),
setTimeout(function ()
{
$.fancybox.close("all");
}, 3e3),
$("input, textarea").val("");
})
.always(function () {
$("input[type=submit], button[type=submit]").removeAttr("disabled");
})
.fail(function (e) {
console.log(e);
}),
!1
);
});
and this div block I’m trying to show after successful sending
<div class="modal" id="thanks">
<div class="modal__title">
Thanks!
</div>
<div class="modal__image">
<svg class="ico-success">
<use xlink:href="assets/img/sprites.svg#success"></use>
</svg>
</div>
<div class="modal__footer">
We will contact you
</div>
</div>
This is my form itself
<div class="modal" id="product">
<form id="prod_form" action="" method="post">
<input type="hidden" name="form" >
<div class="modal__sub">
Contact form
</div>
<div class="modal__title" id="modal-title" >
leave your message here
</div>
<div class="modal__content">
<div class="form-group">
<label for="">name</label>
<input type="text" name="name" value="[[+fi.name]]">
</div>
<div class="form-group">
<label for="">phone</label>
<input type="tel" name="phone" value="[[+fi.phone]]">
</div>
<div class="form-group">
<button type="submit" class="btn">
<svg class="ico-phone">
<use xlink:href="assets/img/sprites.svg#arrow-right"></use>
</svg>
<span>send</span>
</button>
</div>
</div>
</form>
</div>