Проблем с отправкой нет уже. Проблема с закрыванием окна)
У нас два файла:
jqBootstrapValidation и jquery.maskedinput
<script type="text/javascript">
jQuery(function($){
$("#phone").mask("+7 (999) 999-9999");
});
</script>
<script type="text/javascript"><!--
/*
Jquery Validation using jqBootstrapValidation
example is taken from jqBootstrapValidation docs
*/
$(function() {
$("input,textarea").jqBootstrapValidation(
{
preventSubmit: false,
submitError: function($form, event, errors) {
<!-- something to have when submit produces an error ?
<!-- Not decided if I need it yet
},
submitSuccess: function($form, event) {
event.preventDefault(); <!-- prevent default submit behaviour
<!-- get values from FORM
var foproduct = $("input#foproduct").val();
var foprice = $("input#foprice").val();
var fomodel = $("input#fomodel").val();
var fostock = $("input#fostock").val();
var name = $("input#name").val();
var emailcustomer = $("input#emailcustomer").val();
var phone = $("input#phone").val();
var message = $("textarea#message").val();
var firstName = name; <!-- For Success/Failure Message
<!-- Check for white space in name for Success/Fail message
if (firstName.indexOf(' ') >= 0) {
firstName = name.split(' ').slice(0, -1).join(' ');
}
$.ajax({
url: "index.php?route=product/product/fastorder",
type: "POST",
data: {foproduct: foproduct, foprice: foprice, fomodel: fomodel, fostock: fostock, name: name, emailcustomer: emailcustomer, phone: phone, message: message},
cache: false,
success: function() {
<!-- Success message
$('#success').html("<div class='alert alert-success'>");
$('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append( "</button>");
$('#success > .alert-success')
.append("<?php echo $entry_fo_send_success; ?>");
$('#success > .alert-success')
.append('</div>');
<!-- clear all fields
$('#contactForm').trigger("reset");
},
error: function() {
<!-- Fail message
$('#success').html("<div class='alert alert-danger'>");
$('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append( "</button>");
$('#success > .alert-danger').append("<?php echo $entry_fo_send_error; ?>");
$('#success > .alert-danger').append('</div>');
<!-- clear all fields
$('#contactForm').trigger("reset");
},
})
},
filter: function() {
return $(this).is(":visible");
},
});
$("a[data-toggle=\"tab\"]").click(function(e) {
e.preventDefault();
$(this).tab("show");
});
});
/*When clicking on Full hide fail/success boxes */
$('#name').focus(function() {
$('#success').html('');
});
<!-- --></script>