Answer the question
In order to leave comments, you need to log in
How to make a "Thank you for submitting" window after submitting form data using Magnific Popup?
There is a form that pops up using Magnific Popup.
<!-- Форма -->
<div id="form-wrapper" class="form-wrapper">
<form id="form" class="form" name="form">
<input required type="text" class="form__input" name="name" placeholder="ИМЯ">
<input required type="email" class="form__input" name="email" placeholder="E-MAIL">
<input required type="text" class="form__input" name="phone" placeholder="ТЕЛЕФОН">
<button class="form__button">ЗАКАЗАТЬ КОНСУЛЬТАЦИЮ</button>
</form>
</div>
// Форма в модальном окне
$('#popup-form').magnificPopup({
type: 'inline'
});
// Отправка заявки
$(document).ready(function() {
$('#form').submit(function() { // проверка на пустоту заполненных полей. Атрибут html5 — required не подходит (не поддерживается Safari)
if (document.form.name.value == '' || document.form.phone.value == '' || document.form.email.value == '' ) {
valid = false;
return valid;
}
$.ajax({
type: 'POST',
url: 'mail.php',
data: $(this).serialize()
}).done(function() {
$(this).find('input').val('');
$('#form').trigger('reset');
});
return false;
});
});
Answer the question
In order to leave comments, you need to log in
.done(function() {
$(this).find('input').val('');
$('#form').trigger('reset');
//insert info block here like this
$ ('.block').fadeIn().delay(2000).fadeOut();
});
make up the block, style it, write the text you need there, and in css display: none; make a block. delay(2000) will show the block for 2s and hide it,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question