$(function(){
$('#form-order').validate({
rules: {
name: {
required: true
},
phone: {
required: true,
digits: true
},
street: {
required: true
},
home: {
required: true,
digits: true
},
shape: {
digits: true
},
flat: {
required: true,
digits: true
},
floor: {
digits: true
}
},
focusCleanup: true,
focusInvalid: false,
submitHandler: function (form) {
form.submit();
var form = $(this);
if (form.valid()) {
$('#submit').attr('disabled')
$.ajax({
type: "POST",
url: "server.php",
data: form.serialize()
}).done(function () {
$.fancybox.open({
src: '#form-modal',
type: 'inline',
afterClose: function () {
form.trigger("reset");
}
});
});
}
return false;