Last active
May 30, 2022 15:38
-
-
Save frontend-coder/2019eb3b5c27ac96ecf6dca94a5eee75 to your computer and use it in GitHub Desktop.
Форма обратной связи с Аякс, #validate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Аякс отправка форм | |
//Документация: http://api.jquery.com/jquery.ajax/ | |
$(".forms-call").submit(function() { | |
$.ajax({ | |
type: "POST", | |
url: "mail.php", | |
data: $(this).serialize() | |
}).done(function() { | |
alert("Спасибо за заявку! Мы позвоним Вам в рабочее время."); | |
setTimeout(function() { | |
$.magnificPopup.close(); | |
$(".forms-call").trigger("reset"); | |
}, 1000); | |
}); | |
return false; | |
}); | |
PS В корень сайта необходимо поместить файл mail.php, он находится в стартовом шаблоне на GitHab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* стили формы обратной связи */ | |
.forms-call { | |
color:#000; | |
font-size:.875em; | |
} | |
.forms-call label{margin:10px 0; | |
display:block; | |
} | |
.forms-call input, .forms-call textarea{ | |
display:block; | |
width:90%; | |
height:50px; | |
border:1px solid #000; | |
text-indent:10px; | |
padding:10px 0; | |
margin:0 auto; | |
-webkit-transition:all .5s ease; | |
transition:all .5s ease; | |
color:#000; | |
font-size:1.25em; | |
} | |
.forms-call textarea { | |
height:150px; | |
resize: none;overflow:hidden; | |
} | |
.forms-call input:focus, .forms-call textarea:focus{ | |
border:2px solid #8470FF; | |
} | |
.forms-call .get-buttons{ | |
margin:10px auto; | |
width:90%; | |
background-color: #fff; | |
height:50px; | |
line-height: 50px; | |
font-size:1.375em; | |
text-decoration:none; | |
border:1px solid #000; | |
margin-bottom:60px; | |
-moz-transition:all .25s ease; | |
-webkit-transition:all .25s ease; | |
transition:all .25s ease; | |
} | |
.button-call{text-align:center;} | |
.forms-call .get-buttons:focus{ | |
background-color:#707070;color:#fff; | |
} | |
.forms-call .get-buttons:hover{ | |
background-color:#000; | |
color:#fff; | |
} | |
.forms-call .get-buttons:active | |
{background-color:#707070;color:#fff; | |
} | |
/* конец формы обратной связи */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTML | |
<!-- начало формы обратной связи --> | |
<form class="forms-call"> | |
<label> | |
<input type="text" name="name" placeholder="Введите Ваше имя" required> | |
</label> | |
<label> | |
<input type="text" name="phone" placeholder="Введите номер Вашего телефона" required> | |
</label> | |
<label> | |
<textarea name="text" placeholder="Введите сообщение" rows="10" required></textarea> | |
</label> | |
<div class="button-call"> | |
<button class="get-buttons">Отправить</button> | |
<input type="hidden" name="formaone" value="форма размещена над самым футером"> | |
</div> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment