Location:Home > Message

Message

$("#contactForm").validator().on("submit", function (event) { if (event.isDefaultPrevented()) { // handle the invalid form... formError(); submitMSG(false, "Did you fill in the form properly ?"); } else { // everything looks good! event.preventDefault(); submitForm(); } }); function submitForm(){ // Initiate Variables With Form Content var name = $("#name").val(); var email = $("#email").val(); var mobile = $("#mobile").val(); $.ajax({ type: "POST", dataType: "json", url: "/form/", data: $('#contactForm').serialize(), success: function (result) { if (result.code == '0') { alert("Submission Failed"); } else { alert("Submitted successfully"); // window.location.href='/'; window.location.reload(); } }, error : function() { alert("网络异常!"); } }); } function formSuccess(){ $("#contactForm")[0].reset(); submitMSG(true, "Message Submitted!") } function formError(){ $("#contactForm").removeClass().addClass('shake animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ $(this).removeClass(); }); } function submitMSG(valid, msg){ if(valid){ var msgClasses = "h5 text-center tada animated text-success mt-3"; } else { var msgClasses = "h5 text-center text-danger mt-3"; } $("#msgSubmit").removeClass().addClass(msgClasses).text(msg); } }(jQuery)); // End of use strict

Home

Message

Tel

Top