vinh-t
5/3/2018 - 1:52 AM

Ajax

<script src="https://cdn.jsdelivr.net/jquery.validation/1.15.1/jquery.validate.min.js"></script>
<script>
    // Wait for the DOM to be ready
$(function() {
  // Initialize form validation on the registration form.
  // It has the name attribute "registration"
  $("form[name='registration']").validate({
    // Specify validation rules
    rules: {
      // The key name on the left side is the name attribute
      // of an input field. Validation rules are defined
      // on the right side
      firstname: "required",
      requirement: "required",
      email: {
        required: true,
        // Specify that email should be validated
        // by the built-in "email" rule
        email: true
      }
    },
    // Specify validation error messages
    messages: {<
      firstname: "Please enter your name",
      email: "Please enter a valid email address",
      requirement: "Please enter your requirement"
    },
    // Make sure the form is submitted to the destination defined
    // in the "action" attribute of the form when valid
    submitHandler: function(form) {
    	$('#btn__submit').hide();
    	$('#btn__sending').show();
      event.preventDefault();
        var a =  $('input[name=choise]:checked').val();
        var b =  $('#firstname').val();
        var c =  $('#company').val();
        var d =  $('#email').val();
        var e =  $('#phone').val();
         var f =  $('#requirement').val();
        $.ajax({
            url: '/offidon/send_mail.php?a=' + a + '&b=' + b + '&c=' + c + '&d=' + d + '&e=' + e + '&f=' + f,
            success: function (data) {

								$( "body" ).addClass( 'showForm' );
								$("html, body").delay(200).animate({
		scrollTop: $('#top').offset().top
}, 200);
                return true;

            }
        });
        return false;
    }
  });
});

    </script>