Answer the question
In order to leave comments, you need to log in
Submitting the form. How to make users submit a maximum of 2 times the form?
There is such JS code (don't judge strictly, I don't know JS at all). It is necessary that when the form is resubmitted, a window pops up stating that it is impossible to submit the application again. And better after 2 shipments. This is necessary to prevent spam on the phone. Help please, I will be very grateful!)
JS code
// Первая форма
$(document).ready(function() {
var form = $(".subform");
form.submit(function() {
var box = form.find('.message-box');
$.ajax({
type: "POST",
url: "../php/mail.php",
data: $(this).serialize()
}).done(function() {
box.show();
setTimeout(function() {
$.magnificPopup.close();
}, 1000);
});
setTimeout(function(){
box.show();
},300);
return false;
});
});
// Вторая форма
$(document).ready(function() {
var form = $(".subform2");
form.submit(function() {
var box = form.find('.message-box2');
$.ajax({
type: "POST",
url: "../php/mail.php",
data: $(this).serialize()
}).done(function() {
box.show();
setTimeout(function() {
$.magnificPopup.close();
}, 1000);
});
setTimeout(function(){
box.show();
},300);
return false;
});
});
// Третья всплывающая форма
$(document).ready(function() {
$(".popup").magnificPopup();
//Цели для Яндекс.Метрики и Google Analytics
$(".count_element").on("click", (function() {
ga("send", "event", "goal", "goal");
yaCounterXXXXXXXX.reachGoal("goal");
return true;
}));
$("#form").submit(function() {
$.ajax({
type: "POST",
url: "../php/mail.php",
data: $(this).serialize()
}).done(function() {
alert("Спасибо за заявку!");
setTimeout(function() {
$.magnificPopup.close();
}, 1000);
});
return false;
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question