0) { var data = $.data($('#email-form')[0], '.w-form'); data.handler = function (formData) { formData.evt && formData.evt.preventDefault(); formData.evt = null; var allowed_file_size = "5120000"; proceed = true; var vendorForm = formData.form[0]; //check file size and type before upload, works in modern browsers if (window.File && window.FileReader && window.FileList && window.Blob) { var total_files_size = 0; if (vendorForm.elements['file_attach[]']) { $(vendorForm.elements['file_attach[]'].files).each(function (i, ifile) { if (ifile.value !== "") { total_files_size = total_files_size + ifile.size; //add file size to total size } }); } if (total_files_size > allowed_file_size) { alert("Make sure total file size is less than 5 MB!"); proceed = false; } } //if everything's ok, continue with Ajax form submit if (proceed) { var post_url = "https://api.responsival.net/nep/form.php"; //get form action url var request_method = "post"; //get form GET/POST method var form_data = new FormData(vendorForm); //Creates new FormData object $.ajax({ //ajax form submit url: post_url, type: request_method, data: form_data, dataType: "json", contentType: false, cache: false, processData: false }).done(function (res) { //fetch server "json" messages when done if (res.type == "error") { $(".error").html('
' + res.text + "
"); $(".error").fadeIn(500); } if (res.type == "done") { //$("#contact_results").html('
'+ res.text +"
"); $(vendorForm).hide(); $(".error").hide(); $(".success").show(); } }); } }; } });