");
51 | $('#success > .alert-danger').html("");
53 | $('#success > .alert-danger').append("Sorry " + firstName + " it seems that my mail server is not responding... Could you please email me directly to .alert-danger').append('
');
55 | //clear all fields
56 | $('#contactForm').trigger("reset");
57 | },
58 | })
59 | },
60 | filter: function() {
61 | return $(this).is(":visible");
62 | },
63 | });
64 |
65 | $("a[data-toggle=\"tab\"]").click(function(e) {
66 | e.preventDefault();
67 | $(this).tab("show");
68 | });
69 | });
70 |
71 |
72 | /*When clicking on Full hide fail/success boxes */
73 | $('#name').focus(function() {
74 | $('#success').html('');
75 | });
76 |
--------------------------------------------------------------------------------
/target/spring-mvc-app/resources/js/contact_me.js:
--------------------------------------------------------------------------------
1 | /*
2 | Jquery Validation using jqBootstrapValidation
3 | example is taken from jqBootstrapValidation docs
4 | */
5 | $(function() {
6 |
7 | $("#contactForm input,#contactForm textarea").jqBootstrapValidation({
8 | preventSubmit: true,
9 | submitError: function($form, event, errors) {
10 | // something to have when submit produces an error ?
11 | // Not decided if I need it yet
12 | },
13 | submitSuccess: function($form, event) {
14 | event.preventDefault(); // prevent default submit behaviour
15 | // get values from FORM
16 | var name = $("input#name").val();
17 | var phone = $("input#phone").val();
18 | var email = $("input#email").val();
19 | var message = $("textarea#message").val();
20 | var firstName = name; // For Success/Failure Message
21 | // Check for white space in name for Success/Fail message
22 | if (firstName.indexOf(' ') >= 0) {
23 | firstName = name.split(' ').slice(0, -1).join(' ');
24 | }
25 | $.ajax({
26 | url: "./bin/contact_me.php",
27 | type: "POST",
28 | data: {
29 | name: name,
30 | phone: phone,
31 | email: email,
32 | message: message
33 | },
34 | cache: false,
35 | success: function() {
36 | // Success message
37 | $('#success').html("
");
51 | $('#success > .alert-danger').html("");
53 | $('#success > .alert-danger').append("Sorry " + firstName + " it seems that my mail server is not responding... Could you please email me directly to .alert-danger').append('