ACC SHELL
$(function() {
// Get the form.
var form = $('#ajax-support');
// Get the messages div.
var formMessages = $('#form-messages');
// Set up an event listener for the contact form.
$(form).submit(function(event) {
// Stop the browser from submitting the form.
event.preventDefault();
if (!$('#souhlas').is(":checked"))
{
$(formMessages).addClass('error');
$(formMessages).text(errorMess);
return false;
}
// Serialize the form data.
var formData = $(form).serialize();
// Submit the form using AJAX.
$.ajax({
type: 'POST',
url: $(form).attr('action'),
data: formData
})
.done(function(response) {
// Make sure that the formMessages div has the 'success' class.
$(formMessages).removeClass('error');
$(formMessages).addClass('success');
var resp_array = response.split("|");
// Set the message text.
// alert(resp_array);
$(formMessages).text(resp_array[1]);
if (resp_array[0]==1)
{
// Clear the form.
$('#name').val('');
$('#firm').val('');
$('#email').val('');
$('#phone').val('');
$('#product').val('');
$('#version').val('');
$('#snumber').val('');
$('#message').val('');
$('#osystem').val('');
$('#code').val('');
$('#souhlas').prop('checked', false);
$("#img_code").attr("src", $("#img_code").attr("src")+"?timestamp=" + new Date().getTime());
}
else
{
$(formMessages).removeClass('success');
$(formMessages).addClass('error');
$('#code').val('');
$('#souhlas').prop('checked', false);
$("#img_code").attr("src", $("#img_code").attr("src")+"?timestamp=" + new Date().getTime());
}
})
.fail(function(data) {
// Make sure that the formMessages div has the 'error' class.
$(formMessages).removeClass('success');
$(formMessages).addClass('error');
// Set the message text.
if (data.responseText !== '') {
$(formMessages).text(data.responseText);
} else {
$(formMessages).text('Oops! An error occured and your message could not be sent.');
}
});
});
});
ACC SHELL 2018