jQuery(document).ready(function($) {
"use strict";
//Contact
$('form.contactForm').submit(function() {
e.preventDefault();
console.log('Да я сработала');
var f = $(this).find('.form-group'),
ferror = false,
emailExp = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i;
f.children('input').each(function() { // run all inputs
var i = $(this); // current input
var rule = i.attr('data-rule');
if (rule !== undefined) {
var ierror = false; // error flag for current input
var pos = rule.indexOf(':', 0);
if (pos >= 0) {
var exp = rule.substr(pos + 1, rule.length);
rule = rule.substr(0, pos);
} else {
rule = rule.substr(pos + 1, rule.length);
}
switch (rule) {
case 'required':
if (i.val() === '') {
ferror = ierror = true;
}
break;
case 'minlen':
if (i.val().length < parseInt(exp)) {
ferror = ierror = true;
}
break;
case 'email':
if (!emailExp.test(i.val())) {
ferror = ierror = true;
}
break;
case 'checked':
if (! i.is(':checked')) {
ferror = ierror = true;
}
break;
case 'regexp':
exp = new RegExp(exp);
if (!exp.test(i.val())) {
ferror = ierror = true;
}
break;
}
i.next('.validation').html((ierror ? (i.attr('data-msg') !== undefined ? i.attr('data-msg') : 'wrong Input') : '')).show('blind');
}
});
f.children('textarea').each(function() { // run all inputs
var i = $(this); // current input
var rule = i.attr('data-rule');
if (rule !== undefined) {
var ierror = false; // error flag for current input
var pos = rule.indexOf(':', 0);
if (pos >= 0) {
var exp = rule.substr(pos + 1, rule.length);
rule = rule.substr(0, pos);
} else {
rule = rule.substr(pos + 1, rule.length);
}
switch (rule) {
case 'required':
if (i.val() === '') {
ferror = ierror = true;
}
break;
case 'minlen':
if (i.val().length < parseInt(exp)) {
ferror = ierror = true;
}
break;
}
i.next('.validation').html((ierror ? (i.attr('data-msg') != undefined ? i.attr('data-msg') : 'wrong Input') : '')).show('blind');
}
});
if (ferror) return false;
else var str = $(this).serialize();
$.ajax({
type: "POST",
url: "contactform/contactform.php",
data: str,
success: function() {
alert("Спасибо за заявку! Скоро мы с вами свяжемся.");
$('#forma').modal('hide');
},
fail: function() {
alert("Не правильно введены данные, повторите еще раз");
}
});
return false;
});
});
@font-face {
font-family: 'Gotham Pro Black';
src: url('/fonts/GothamPro-Black.eot');
src: url('/fonts/GothamPro-Black.eot?#iefix') format('embedded-opentype'),
url('/fonts/GothamPro-Black.woff') format('woff'),
url('/fonts/GothamPro-Black.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Gotham Pro Medium';
src: url('/fonts/GothamPro-Medium.eot');
src: url('/fonts/GothamPro-Medium.eot?#iefix') format('embedded-opentype'),
url('/fonts/GothamPro-Medium.woff') format('woff'),
url('/fonts/GothamPro-Medium.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Museo Sans 900 Black';
src: url('/fonts/MuseoSansCyrl-900.eot');
src: url('/fonts/MuseoSansCyrl-900.eot?#iefix') format('embedded-opentype'),
url('/fonts/MuseoSansCyrl-900.woff') format('woff'),
url('/fonts/MuseoSansCyrl-900.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Gotham Pro Regular';
src: url('/fonts/GothamPro.eot');
src: url('/fonts/GothamPro.eot?#iefix') format('embedded-opentype'),
url('/fonts/GothamPro.woff') format('woff'),
url('/fonts/GothamPro.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Myriad Pro Regular';
src: url('/fonts/MyriadPro-Regular.eot');
src: url('/fonts/MyriadPro-Regular.eot?#iefix') format('embedded-opentype'),
url('/fonts/MyriadPro-Regular.woff') format('woff'),
url('/fonts/MyriadPro-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}