jquery on form submit call function

JavaScript
$(document).ready(function() {
  $("your form selector here").submit(function() {


    // do the extra stuff here
    $.ajax({
     type: "POST",
      url: "mail.php",
      data: $(this).serialize(),
      success: function() {
        $('.simple-sucess').fadeIn(100).show();
        $('.contact_form').fadeOut(100).hide();
        $('.simple_error').fadeOut(100).hide();

       }
    })

  })
})

Source

Also in JavaScript: