1function wpzf_submit(token) { 2 // Check if required inputs are filled 3 var allInputsFilled = true; 4 5 jQuery('form.wpzoom-forms_form [required]').each(function() { 6 var input = jQuery(this); 7 if (input.is(':checkbox')) { 8 // For checkboxes 9 if (!input.is(':checked')) { 10 allInputsFilled = false; 11 input.focus(); 12 return false; // exit the loop if any required checkbox is not checked 13 } 14 } else { 15 // For non-checkbox inputs (text, password, etc.) 16 if ( ! input.val() ) { 17 allInputsFilled = false; 18 input.focus(); 19 return false; // exit the loop if any required input is not filled 20 } 21 } 22 } ); 23 24 if ( allInputsFilled ) { 25 // All required inputs are filled, trigger form submission 26 jQuery('form.wpzoom-forms_form').trigger('submit'); 27 } 28} 29 30(function ($) { 31 'use strict'; 32 33 $('.wp-block-wpzoom-forms-multi-checkbox-field').each(function() { 34 35 var $this = $(this); 36 var $checkboxes = $this.find('input[type="checkbox"]:required'); 37 38 // Check if any checkbox is initially checked 39 var anyChecked = false; 40 $checkboxes.each(function() { 41 if ($(this).prop('checked')) { 42 anyChecked = true; 43 return false; // Exit the loop early since we found a checked checkbox 44 } 45 }); 46 47 // If any checkbox is initially checked, remove the required attribute 48 if (anyChecked) { 49 $checkboxes.removeAttr('required'); 50 } 51 52 $checkboxes.on('change', function() { 53 var atLeastOneChecked = false; 54 55 // Check if at least one checkbox is checked 56 $checkboxes.each(function() { 57 if ($(this).prop('checked')) { 58 atLeastOneChecked = true; 59 return false; // Exit the loop early since we found a checked checkbox 60 } 61 }); 62 63 // If at least one checkbox is checked, remove the required attribute 64 if (atLeastOneChecked) { 65 $checkboxes.removeAttr('required'); 66 } else { 67 // If no checkbox is checked, add the required attribute back 68 $checkboxes.attr('required', 'required'); 69 } 70 }); 71 72 }); 73 74 75 76})(jQuery);
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.