You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.4 KiB
88 lines
2.4 KiB
2 months ago
|
$(document).ready(function () {
|
||
|
$('#submit_form').on("click", function()
|
||
|
{
|
||
|
var name = $('#form_name').val();
|
||
|
var company = $('#form_company').val();
|
||
|
var tel = $('#form_tel').val();
|
||
|
var email = $('#form_email').val();
|
||
|
var text = $('#form_text').val();
|
||
|
$('#successAlert').hide(1000);
|
||
|
$('#failAlert').hide(1000);
|
||
|
var success = true;
|
||
|
if(name.length == 0)
|
||
|
{
|
||
|
$('#form_name').css("background-color", "#ffaaaa");
|
||
|
success = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$('#form_name').css("background-color", "#fff");
|
||
|
}
|
||
|
if(company.length == 0)
|
||
|
{
|
||
|
$('#form_company').css("background-color", "#ffaaaa");
|
||
|
success = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$('#form_company').css("background-color", "#fff");
|
||
|
}
|
||
|
if(tel.length == 0)
|
||
|
{
|
||
|
$('#form_tel').css("background-color", "#ffaaaa");
|
||
|
success = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$('#form_tel').css("background-color", "#fff");
|
||
|
}
|
||
|
if(email.length == 0)
|
||
|
{
|
||
|
$('#form_email').css("background-color", "#ffaaaa");
|
||
|
success = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$('#form_email').css("background-color", "#fff");
|
||
|
}
|
||
|
if(text.length == 0)
|
||
|
{
|
||
|
$('#form_text').css("background-color", "#ffaaaa");
|
||
|
success = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$('#form_text').css("background-color", "#fff");
|
||
|
}
|
||
|
if(success==true)
|
||
|
{
|
||
|
console.log('sending');
|
||
|
var message = {
|
||
|
name: name,
|
||
|
company:company,
|
||
|
tel:tel,
|
||
|
email:email,
|
||
|
text:text
|
||
|
}
|
||
|
$.ajax({
|
||
|
type:'POST',
|
||
|
url: '/api/mail/send',
|
||
|
processData: false, // tell jQuery not to process the data
|
||
|
contentType: false, // tell jQuery not to set contentType
|
||
|
data: JSON.stringify(message),
|
||
|
success: (data) => {
|
||
|
|
||
|
if(data=='True'){
|
||
|
$('#successAlert').show(1000);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$('#failAlert').show(1000);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
$('#callback_form')[0].reset();
|
||
|
}
|
||
|
|
||
|
});
|
||
|
});
|