Tutaj kod HTML:
</div>
<div class="row contact-form">
<div class="col-lg-8 col-lg-offset-2">
<div class="row">
<div class="col-lg-4"><input type="name" class="form-control" id="contact_name" placeholder="Twoje Imię"></div>
<div class="col-lg-4"><input type="email" class="form-control" id="contact_email" placeholder="Twój Adres E-Mail"></div>
<div class="col-lg-4"><input type="phone" class="form-control" id="contact_phone" placeholder="Twój Numer Telefonu"></div>
</div>
<div class="row">
<div class="col-lg-12 text-center">
<textarea class="form-control" id="contact_message" placeholder="Twoja Wiadomość"></textarea><br />
<button type="button" class="btn btn-info" onclick="contact_send;">Wyślij</button>
</div>
i JS:
// CONTACT FORM FUNCTION
var contact_send = function(){
'use strict';
var name = $("#contact_name").val();
var email = $("#contact_email").val();
var phone = $("#contact_phone").val();
var message = $("#contact_message").val();
if ( name=="" ){ alert("Your name is empty!"); $("#contact_name").focus(); }
else if ( email=="" ){ alert("Your email address is empty!"); $("#contact_email").focus(); }
else if ( phone=="" ){ alert("Your phone number is empty!"); $("#contact_phone").focus(); }
else if ( message=="" ){ alert("Your message is empty!"); $("#contact_message").focus(); }
else {
$.post("contact.send.php", { name:name, email:email, phone:phone, message:message }, function( result ){
if ( result=="SUCCESS" ){
alert("Your contact form is sent.");
setTimeout(function(){
$("#contact_name").val("");
$("#contact_email").val("");
$("#contact_phone").val("");
$("#contact_message").val("");
}, 3000);
} else {
alert("Your contact form isn't sent. Please check fields and try again.");
}
});
}
};