1jQuery(document).ready(($) => { 2 $(".rform-button-submit").on("click", function (event) { 3 event.preventDefault(); 4 var form = $(this).closest("form"); 5 var form_id = form.attr("data-form"); 6 if (form.hasClass("rform-dsb")) { 7 var m = form.find(".require-login"); 8 m.css("display", "block"); 9 } else { 10 form.find(".rform-select").each(function () { 11 if ($(this).is("[required]")) { 12 var value = $(this) 13 .closest(".rform-select-container") 14 .find(".rform-select-input") 15 .val(); 16 if (value === "") { 17 $(this).attr("aria-invalid", "true"); 18 } else { 19 $(this).attr("aria-invalid", "false"); 20 } 21 } 22 }); 23 24 // RADIO 25 form.find(".rform-input[type=radio][required]").each(function () { 26 $(this).on("change", function () { 27 const groupName = $(this).attr("name"); 28 form 29 .find(`.rform-input[type=radio][name="${groupName}"]`) 30 .attr("aria-invalid", "false"); 31 }); 32 }); 33 34 // CHECKBOX 35 let checkbox = form.find(".rform-checkbox-button[required]"); 36 37 if (checkbox.length) { 38 checkbox.each(function () { 39 const $checkbox = $(this); 40 const min = parseInt($checkbox.data("min")) || 1; 41 const max = $checkbox.data("max") 42 ? parseInt($checkbox.data("max")) 43 : null; 44 const groupName = $checkbox 45 .find(".rform-input[type=checkbox]") 46 .attr("name"); 47 48 const group = $checkbox.find( 49 `.rform-input[type=checkbox][name="${groupName}"]`, 50 ); 51 52 validateGroup(); // validasi awal 53 54 function validateGroup() { 55 const checkedCount = group.filter(":checked").length; 56 const isValid = 57 max !== null 58 ? checkedCount >= min && checkedCount <= max 59 : checkedCount >= min; 60 group.each(function () { 61 $this = $(this); 62 $this.attr("aria-invalid", !isValid ? "true" : "false"); 63 // console.log($this.attr('aria-invalid')); 64 }); 65 } 66 67 group.on("change", validateGroup); 68 }); 69 } 70 71 if (form[0].checkValidity()) { 72 if (form.find("[aria-invalid=true]").length == 0) { 73 // console.log('Form Valid'); 74 75 $(this).prop("disabled", true); 76 77 let current_html = $(this).html(); 78 79 $(this).html( 80 `<div class="loading"><div id="loading"></div>Sending...</div>`, 81 ); 82 var data = form.serializeArray(); 83 let captchaToken; 84 85 // recaptcha V3 86 let recaptchaV3 = form.find(".rform-recaptcha-token"); 87 if (recaptchaV3.length > 0) { 88 if (recaptchaV3.val() !== "") { 89 captchaToken = recaptchaV3.val(); 90 } 91 } 92 var serializedInputs = {}; 93 var nonce = romethemeform_ajax_url.nonce; 94 data = data.filter(function (item) { 95 return item.name !== "g-recaptcha-response"; 96 }); 97 $(data).each(function (index, obj) { 98 if (serializedInputs[obj.name] !== undefined) { 99 if (!Array.isArray(serializedInputs[obj.name])) { 100 serializedInputs[obj.name] = [serializedInputs[obj.name]]; 101 } 102 serializedInputs[obj.name].push(obj.value); 103 } else { 104 serializedInputs[obj.name] = obj.value; 105 } 106 }); 107 108 var jsonString = JSON.stringify(serializedInputs); 109 var data_sending = { 110 action: "rformsendform", 111 id: form_id, 112 data: jsonString, 113 email: form.find('input[type="email"]').val(), 114 nonce: nonce, 115 page: window.location.href, 116 }; 117 118 if ( 119 captchaToken !== undefined || 120 captchaToken !== "" || 121 captchaToken !== null || 122 captchaToken.length > 0 123 ) { 124 data_sending["recaptchaToken"] = captchaToken; 125 } 126 // console.log(data_sending); 127 sending_form(data_sending, $(this), current_html); 128 } else { 129 form.find(":invalid").each(function () { 130 $(this).attr("aria-invalid", "true"); 131 }); 132 } 133 } else { 134 // console.log('haii') 135 form.find(":invalid").each(function () { 136 $(this).attr("aria-invalid", "true"); 137 }); 138 } 139 } 140 }); 141 $(".close-msg").click(function (event) { 142 event.preventDefault(); 143 var msg = $(this).closest(".msg"); 144 msg.css("display", "none"); 145 }); 146}); 147 148function sending_form(data, btn, current_html) { 149 jQuery(document).ready(($) => { 150 $.ajax({
151 type: "post", 152 url: romethemeform_ajax_url.ajax_url, 153 data: data, 154 success: (e) => { 155 if (e.success) { 156 btn.prop("disabled", false); 157 btn.html(current_html); 158 btn.closest("form").find(".success-submit").css("display", "block"); 159 btn.closest("form")[0].reset(); 160 } else { 161 btn.prop("disabled", false); 162 btn.html(current_html); 163 alert(e.data); 164 } 165 // console.log(e); 166 }, 167 error: (jqXHR, textStatus, errorThrown) => { 168 console.log(textStatus, errorThrown); 169 }, 170 }); 171 }); 172} 173 174function onRecaptchaSuccess() { 175 console.log("Recaptcha berhasil diselesaikan!"); 176} 177function onRecaptchaExpired() { 178 console.log("Recaptcha telah kedaluwarsa. Silakan selesaikan lagi."); 179}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.