$("#newsletterForm").validator().on("submit", function (event) {
//alert();
if (event.isDefaultPrevented()) {
// handle the invalid form...
formErrorNs();
submitMSGNs(false, "You did not fill out the form correctly");
} else {
// everything looks good!
event.preventDefault();
submitFormNs();
}
});
function submitFormNs(){
// Initiate Variables With Form Content
var json = $("#newsletterForm").serialize();
$.ajax({
type: "POST",
url: "https://www.wavesofsilk.com/sending-form-newsair.php",
data: json,
success : function(text){
//alert(text);
if (text == "successNs"){
formSuccessNs();
} else {
formError();
submitMSGNs(false,text);
}
}
});
}
function formSuccessNs(){
$("#newsletterForm")[0].reset();
submitMSGNs(true, "Registration successful !")
}
function formErrorNs(){
$("#newsletterForm").removeClass().addClass("").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function(){
$(this).removeClass();
});
}
function submitMSGNs(validNs, msgNs){
if(validNs){
var msgClasses = "h3 text-center tada animated bg-light text-success";
} else {
var msgClasses = "h3 text-center text-danger";
}
$("#msgSubmitNs").removeClass().addClass(msgClasses).text(msgNs);
}