Имеется такая форма. Письма приходят, всё хорошо. Но если при отправке формы нажать на кнопку "Отправить" несколько раз, то придет сразу несколько писем. Как избежать этого. Пробовал event.stopPropagation() и event.stopImmediatePropagation(), ничего не помогает
$('.callme-form').submit(function(event) {
event.preventDefault();
$.ajax({
type: "POST",
url: 'mail.php',
data: $(this).serialize()
}).done(function() {
alert('Thanks');
});
});
.callme-form {
max-width: 380px;
width: 100%;
margin: 0 auto;
}
div {
position: relative;
}
input,
textarea {
border: 1px solid #3d3d3d;
width: 100%;
font-family: "Lato", sans-serif;
font-size: 14px;
line-height: 32px;
padding: 5px 10px;
margin-bottom: 20px;
outline: none;
background: #2e2e2b;
color: #fff;
border-radius: 4px;
box-sizing: border-box;
}
textarea {
resize: none;
min-height: 100px;
padding: 5px 10px;
}
.btn-submit {
width: 100%;
color: #161613;
background-color: #ffba00;
padding: 10px;
font-size: 24px;
line-height: 54px;
font-weight: bold;
border: none;
box-shadow: none;
display: inline-block;
text-align: center;
text-transform: uppercase;
text-decoration: none;
display: inline-block;
-webkit-transition: 0.4s ease;
transition: 0.4s ease;
border-radius: 4px;
outline: none;
}
i {
font-size: 28px;
margin-right: 7px;
}
label {
color: #fff;
position: absolute;
top: 12px;
left: 20px;
transition: 0.28s ease;
}
span {
color: #ffba00;
}
input+label,
textarea+label {
left: 10px;
font-size: 12px;
}
input:focus+label,
textarea:focus+label {
display: none;
}
input:invalid,
input:valid {
border: none;
box-shadow: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form class="callme-form">
<div>
<input type="text" id="name-subscribe" name="name" required="required" placeholder="Имя">
</div>
<div>
<input type="tel" id="phone-field" name="phone" required="required" placeholder="Телефон">
</div>
<div>
<textarea name="comments" id="comment-field"></textarea>
</div>
<div class="aligncenter">
<button type="submit" class="btn-submit"><i class="fa fa-check" aria-hidden="true"></i> Отправить</button>
</div>
</form>
disabled
Не ? – Не быть рабом на Руси 12 мар '19 в 13:51