1/*
2--------------------------------
3Ajax Contact Form
4--------------------------------
5+ https://github.com/mehedidb/Ajax_Contact_Form
6+ A Simple Ajax Contact Form developed in PHP with HTML5 Form validation.
7+ Has a fallback in jQuery for browsers that do not support HTML5 form validation.
8+ version 1.0.1
9+ Copyright 2016 Mehedi Hasan Nahid
10+ Licensed under the MIT license
11+ https://github.com/mehedidb/Ajax_Contact_Form
12*/
13
14(function ($, window, document, undefined) {
15 'use strict';
16
17 var $form = $('#contact-form');
18
19 $form.submit(function (e) {
20 // remove the error class
21 $('.form-group').removeClass('has-error');
22 $('.help-block').remove();
23
24 // get the form data
25 var formData = {
26 'name' : $('input[name="form-name"]').val(),
27 'email' : $('input[name="form-email"]').val(),
28 'phone' : $('input[name="form-phone"]').val(),
29 'message' : $('textarea[name="form-message"]').val()
30 };
31
32 // process the form
33 $.ajax({
34 type : 'POST',
35 url : 'process.php',
36 data : formData,
37 dataType : 'json',
38 encode : true
39 }).done(function (data) {
40 // handle errors
...
</html>