File: D:/HostingSpaces/SBogers10/immoginis.komma.pro/wwwroot/js/freeEstimationForm.js
/**
* Created by Pascal on 13/04/16.
*/
$(function () {
$('#freeEstimationForm #sendButton').click(function () {
var send = true;
var sendValue = {
name: $('#freeEstimationForm #name').val(),
sur_name: $('#freeEstimationForm #sur_name').val(),
email: $('#freeEstimationForm #email').val(),
phone: $('#freeEstimationForm #phone').val(),
extra_message: $('#freeEstimationForm #extra_message').val(),
type: $('#freeEstimationForm #typeSelectField').val(),
address: $('#freeEstimationForm #address').val(),
secretCode: 'isHuman'
};
$('.check-alert').removeClass('show');
$('.input-rows .alert').removeClass('alert');
$('.check-alert.temp').remove();
if (sendValue.name == '') {
send = false;
$('#freeEstimationForm #name').addClass('alert');
}
if (sendValue.sur_name == '') {
send = false;
$('#freeEstimationForm #sur_name').addClass('alert');
}
if (sendValue.email == '') {
send = false;
$('#freeEstimationForm #email').addClass('alert');
}
if (sendValue.phone == '') {
send = false;
$('#freeEstimationForm #phone').addClass('alert');
}
if (sendValue.address == '') {
send = false;
$('#freeEstimationForm #address').addClass('alert');
}
if (sendValue.type == '') {
send = false;
$('#freeEstimationForm #typeSelectField').addClass('alert');
}
if (send) {
$.ajax({
method: "POST",
data: sendValue,
url: $('#freeEstimationForm').attr('action')
}).done(function (msg) {
console.log(msg);
$errorHtml = '';
if (msg != 'true') {
msg.forEach(function(element) {
$errorHtml += '<p class="notification alert">' + element + '</p>';
});
$('#freeEstimationForm .error-area').html($errorHtml);
}
else {
$('#freeEstimationForm .error-area').innerHTML = '';
var heightForm = $('.o-free-estimation').height();
$('#sendButton').remove();
$('#freeEstimationForm').remove();
$('.o-free-estimation__thanks').addClass('is-visible');
$('.o-free-estimation').height(heightForm);
// $('.o-free-estimation').addClass('min-height');
// $('.thanks').show();
$([document.documentElement, document.body]).animate({
scrollTop: $(".o-free-estimation__title").offset().top - 230
}, 600);
}
});
}
else {
$([document.documentElement, document.body]).animate({
scrollTop: $(".input-rows .alert").offset().top - 230
}, 600);
}
});
});