Sign up to receive race updates, promotions& special offers straight to your inbox
").insertBefore($1touchform70530); } return $("#1touchform70530Error"); }, errorsWrapper: '
', errorElem: '' }, listeners: { onFormValidate: function(isFormValid, event) { if (isFormValid) { console.log('valid'); $('#1touchform70530_70530 button[type="submit"]').prop('disabled', true); try{ //const form = document.getElementById("1touchform70530_70530"); const form = $("#1touchform70530_70530").serialize(); var formData = new FormData($("#1touchform70530_70530")[0]); // Right object? console.log(formData); $('#1touchform70530_70530').find('input[type="file"]').each(function() { var files = $(this).prop('files'); console.log("files:",files[0]) // files is a FileList object containing the selected files // Perform operations on the files here, such as accessing their name, size, or type for(var i = 0; i < files.length; i++){ console.log('File name:', files[i].name); console.log('File size:', files[i].size); console.log('File type:', files[i].type); formData.append('files', files[0]); } }); formData.append('ajax_action', 'form'); formData.append('ajax_method', 'proxy'); formData.append('ajax_preventDuplicates', 'true'); /* When logging a formData object with just console.log(formData) it always returns empty, as you can't log formData. If you just have to log it before sending it, you can use entries() to get the entries in the formData object */ for (var key of formData.entries()) { console.log(key[0] + ', ' + key[1]); } var object = {}; formData.forEach((value, key) => { object[key] = value; //console.log(value); }); var json = JSON.stringify(object); console.log("JSON.stringify:", json); const myFiles = formData.getAll('file'); console.log(myFiles); //console.log("Form Data:", formData); } catch(error) { console.log("Error:", error.message) } finally{ console.log("Done.",!$1touchform70530.attr("action").length); //$('#1touchform70530_70530 button[type="submit"]').prop('disabled', false); } if (!$1touchform70530.attr("action").length) { $.ajax({ type: "POST", url: "/proxy.cfm", data: formData, processData: false, contentType: false, cache: false, dataType: "json", success: function(json) { var successList = ""; $.each(json.DATA, function(item) { successList += json.DATA[item]; }); $1touchform70530[0].reset(); $("#dynamicform_70530").hide();$("#csf70530 .form-errors").empty().fadeOut(); $("#csf70530 .form-success").html(successList).fadeIn(); // GA event //ga('send', 'event', 'Form', 'Entry', 'Join Our Newsletter'); $('html, body').animate({ scrollTop: $('#csf70530 .form-success').offset().top - 50 }, "slow"); }, error: function (request, textStatus, errorThrown) { var resetCaptchaVersion = false; $('#1touchform70530_70530 button[type="submit"]').prop('disabled', false); //console.log("Request Data:", request); //console.log("responseText:", request.responseText); if(request.status == 500) { $(".form-errors").html("
An error has occurred processing your submission. Please try again at a later time.
").fadeIn(); } else if(request.status == 412) { var jsonData = $.parseJSON(request.responseText) errorList = ""; if(typeof jsonData =='object') { $.each(jsonData.DATA, function(item) { errorList += "
" + jsonData.DATA[item] + "
"; /* if (jsonData.DATA[item].toLowerCase().indexOf("The CAPTCHA submitted with your form was invalid.") >= 0){ resetCaptchaVersion = true; } */ }); /* if(resetCaptchaVersion){ $('#g-recaptcha-version').val('v2'); $('#captchaV2Checkbox_1touchform70530_70530').css('display', 'block'); } */ //console.log("Reset Captcha Version:", resetCaptchaVersion); //console.log($('#g-recaptcha-version').val()); $("#csf70530 .form-errors").html(errorList).fadeIn(); }$("#csf70530 .form-errors, parsley-container").fadeIn();var offset = $("#csf70530 .form-errors").offset().top - 50;$("html, body").animate({'scrollTop': offset}, "slow"); } /*// The captcha token was already used, so refresh it if (useCaptcha70530 == "Y" && reCaptchaVersion == "v3") { googleCaptcha70530(); } */ } }); return false; } } else { //console.log(isFormValid); //console.log(event); $("#csf70530 .form-errors, parsley-container").fadeIn();var offset = $("#csf70530 .form-errors").offset().top - 50;$("html, body").animate({'scrollTop': offset}, "slow"); } } } }); });