/* On DOM Load =========== */ $(document).ready(function() { // When check all button is pressed, tick all fair dates $("#check-all-dates-button").on("click", function(event) { event.preventDefault(); fSelectAllFairDates(); }); // Make the first name input field focused by default but only if not on mobile if (window.innerWidth >= 1300) { $("#name-input").focus(); } }); /* fSelectAllFairDates() ===================== Marks all checkboxes for fairs dates (EG selects them all as to exhibit at each one) */ function fSelectAllFairDates() { $(".fair-date-checkbox").prop("checked", true); } /* fToggleCheckbox =============== */ function fToggleCheckbox(sTarget){ var checkbox = $('#' + sTarget); checkbox.prop('checked', !checkbox.prop('checked')); } /* fchkfrm ======= */ function fchkfrm() { // form fields var sExhibitApply_Name = document.getElementById('sExhibitApply_Name').value.trim(); var sExhibitApply_CompanyName = document.getElementById('sExhibitApply_CompanyName').value.trim(); var sExhibitApply_Tel = document.getElementById('sExhibitApply_Tel').value.trim(); var sExhibitApply_Email = document.getElementById('sExhibitApply_Email').value.trim(); // form verification var sErr = ""; if (sExhibitApply_Name=="") { sErr+="\n - Your name"; } if (sExhibitApply_CompanyName=="") { sErr+="\n - Company name"; } if (sExhibitApply_Tel=="") { sErr+="\n - Tel"; } if (fCheckEmail(sExhibitApply_Email)=="invalid") { sErr+="\n - Email"; } if ($('.fair-date-checkbox:checked').length === 0) { sErr+="\n - Which fair dates would you like to exhibit at?"; } if ($('#bExhibitApply_PrivacyPolicy:checked').length === 0) { sErr+="\n - Please tick the Privacy Policy box to confirm you've read our Privacy Policy before continuing."; } // Google recpatcha var response = grecaptcha.getResponse( $('#recaptcha1').attr('data-widget-id') ); if (response.length > 0) { } else{ sErr+="\n - Please tick I'm not a robot"; } // Is there an error? if (sErr!="") { alert("Please complete the following information:\n" + sErr); return false; } // No error submit the form return true; }