$(function() {

    $("#contactForm input,#contactForm textarea").jqBootstrapValidation({
        preventSubmit: true,
        submitError: function($form, event, errors) {
            // additional error messages or events
        },
        submitSuccess: function($form, event) {
            // Prevent spam click and default submit behaviour
            $("#btnSubmit").attr("disabled", true);
            event.preventDefault();
            
            // get values from FORM
            var name = $("input#name").val();
            var email = $("input#email").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: "https://lit-brushlands-56940.herokuapp.com/",
                type: "POST",
                data: {
                    name: name,
                    phone: phone,
                    email: email,
                    message: message
                },
                cache: false,
                success: function() {
                    // Enable button & show success message
                    $("#btnSubmit").attr("disabled", false);
                    $('#success').html("<div class='alert alert-success'>");
                    $('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;")
                        .append("</button>");
                    $('#success > .alert-success')
                        .append("<strong>Your message has been sent. </strong>");
                    $('#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'>&times;")
                        .append("</button>");
                    $('#success > .alert-danger').append("<strong>Sorry " + firstName + ", it seems that my mail server is not responding. Please try again later!");
                    $('#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('');
});

@@ -1,22 +1,23 @@
 $(function
+ 
 () %7B%0A%0A    $(
@@ -134,32 +134,33 @@
 tError: function
+ 
 ($form, event, e
@@ -261,16 +261,17 @@
 function
+ 
 ($form, 
@@ -430,28 +430,16 @@
 ault();%0A
-            
 %0A       
@@ -1282,32 +1282,33 @@
 uccess: function
+ 
 () %7B%0A           
@@ -2048,32 +2048,33 @@
  error: function
+ 
 () %7B%0A           
@@ -2084,16 +2084,19 @@
       //
+ //
  Fail me
@@ -2112,32 +2112,35 @@
                 
+ //
  $('#success').h
@@ -2191,32 +2191,35 @@
                 
+ //
  $('#success %3E .
@@ -2336,32 +2336,35 @@
                 
+ //
      .append(%22%3C/
@@ -2385,32 +2385,35 @@
                 
+ //
  $('#success %3E .
@@ -2554,32 +2554,35 @@
                 
+ //
  $('#success %3E .
@@ -2610,24 +2610,800 @@
 ('%3C/div%3E');%0A
+                    // //clear all fields%0A                    // $('#contactForm').trigger(%22reset%22);%0A%0A                    // Enable button & show success message because No 'Access-Control-Allow-Origin' header is present%0A                    $(%22#btnSubmit%22).attr(%22disabled%22, false);%0A                    $('#success').html(%22%3Cdiv class='alert alert-success'%3E%22);%0A                    $('#success %3E .alert-success').html(%22%3Cbutton type='button' class='close' data-dismiss='alert' aria-hidden='true'%3E&times;%22)%0A                        .append(%22%3C/button%3E%22);%0A                    $('#success %3E .alert-success')%0A                        .append(%22%3Cstrong%3EYour message has been sent. %3C/strong%3E%22);%0A                    $('#success %3E .alert-success')%0A                        .append('%3C/div%3E');%0A%0A
             
@@ -3547,32 +3547,33 @@
 filter: function
+ 
 () %7B%0A           
@@ -3670,16 +3670,17 @@
 function
+ 
 (e) %7B%0A  
@@ -3821,16 +3821,17 @@
 function
+ 
 () %7B%0A   

change mail UI response