1function regenerateTs(resultCallback) 2{ 3 if (!document.$$formBuilderInit) { 4 document.$$formBuilderInit = true; 5 jQuery.ajax({ 6 type: 'GET', 7 url: '/forms2/getToken', 8 contentType: "text/html;charset=UTF-8", 9 cache: false, 10 success: function (token) { 11 if (resultCallback) { 12 resultCallback(token); 13 } else { 14 jQuery(".frm-bldr input[name*='data[Forms2][system][ts]']").val(token); 15 } 16 document.$$formBuilderInit = false; 17 }, 18 error: function() { 19 document.$$formBuilderInit = false; 20 } 21 }); 22 } 23} 24 25 26jQuery(document).ready(function() { 27 28 // Overrule default jquery email validation 29 jQuery.validator.methods.email = function(value, element) { 30 return this.optional(element) || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value); 31 }; 32 33 if (jQuery.validator) { 34 jQuery.validator.addMethod("phone", function(value, element) { 35 return this.optional(element) || /^\d+$/.test(value); 36 }, "Only numbers are allowed."); 37 38 jQuery.validator.messages.phone = "Only numbers are allowed."; 39 } 40 41 jQuery.each(jQuery('.frm-bldr'), function(index, el) { 42 var validator = jQuery(el).validate(); 43 44 var phoneFields = jQuery(el).find('input.phone'); 45 46 phoneFields.each(function() { 47 if (!validator.settings.messages[this.name]) { 48 validator.settings.messages[this.name] = {}; 49 } 50 51 validator.settings.messages[this.name].phone = 'Only numbers are allowed.'; 52 53 jQuery(this).rules('add', { 54 phone: true, 55 messages: { 56 phone: 'Only numbers are allowed.' 57 } 58 }); 59 }); 60 }); 61 62 var checkboxIsChecked = true; 63 64 jQuery('.frm-bldr input[type=submit]').removeAttr('disabled'); 65 66 jQuery('.frm-bldr input[type=submit]').click(function() { 67 68 var checkboxIsRequired = false; 69 var countRequiredCheckbox = 0; 70 var ariaInvalidNotFalse = 0; 71 72 countRequiredCheckbox = jQuery(this).parent().parent().parent().find('.required_checkbox').length; 73 ariaInvalidNotFalse = jQuery(this).parent().parent().parent().find('li.checkbox :input[type=hidden]:not([aria-invalid="false"])').length; 74 75 checkboxIsRequired = countRequiredCheckbox > 0 ? true : false; 76 77 var v = grecaptcha.getResponse(); 78 79 if (v.length === 0) { 80 document.getElementById('g-captcha-error-message').innerHTML="Please confirm captcha"; 81 return false; 82 } 83 84 85 if (jQuery(this).parents('.frm-bldr').valid()) { 86 87 jQuery('[required]').each(function() { 88 if (jQuery(this).is(':invalid') || !jQuery(this).val()) { 89 if (jQuery(this).is(':checkbox')) { 90 let parentCheckBoxChecked = jQuery(this).parent().parent().parent().find('input[type=checkbox]:checked').length; 91 return parentCheckBoxChecked >= 1; 92 } else if (jQuery(this).is(':radio')) { 93 let parentRadioChecked = jQuery(this).parent().parent().parent().find('input[type=radio]:checked').length; 94 return parentRadioChecked >= 1; 95 } 96 else { 97 return false; 98 } 99 } 100 }) 101 102 if(checkboxIsRequired){ 103 if(ariaInvalidNotFalse === 0 && checkboxIsChecked) { 104 jQuery(this).hide(); 105 jQuery('.checkbox_error').remove(); 106 jQuery(this).parent().append('<div class="submit-loading"></div>'); 107 return true; 108 }else{ 109 jQuery('.checkbox_error').remove(); 110 jQuery(this).parent().append('<div style="color:red;" class="checkbox_error">The checkbox field is required.</div>'); 111 return false;
112 } 113 }else{ 114 jQuery(this).hide(); 115 jQuery('.checkbox_error').remove(); 116 jQuery(this).parent().append('<div class="submit-loading"></div>'); 117 return true; 118 } 119 }else{ 120 return false; 121 } 122 }); 123 124 regenerateTs(function(token){ 125 jQuery('.frm-bldr').append('<input type="hidden" name="data[Forms2][system][ts]" value="' + token + '" />'); 126 }) 127 128 129 130 setInterval("regenerateTs()", 300000); 131 132 jQuery('li.checkbox :input[type=checkbox]').click(function(e) { 133 if(jQuery(this).parent().parent().parent().find('input[type=checkbox]:checked').length > 0){ 134 checkboxIsChecked = true; 135 if (jQuery(this).parent().parent().parent().find('.required_checkbox').length > 0) { 136 jQuery(this).parent().parent().parent().find('.required_checkbox').valid(); 137 } 138 }else{ 139 checkboxIsChecked = false; 140 } 141 }); 142 143 jQuery('li.radio input[type=radio]').click(function() { 144 if (jQuery(this).parent().parent().parent().find('.required_radio').length > 0) { 145 jQuery(this).parent().parent().parent().find('.required_radio').valid(); 146 } 147 }); 148 149 jQuery('li.radio_yes_no input[type=radio]').click(function() { 150 if (jQuery(this).parent().parent().parent().find('.required_radio').length > 0) { 151 jQuery(this).parent().parent().parent().find('.required_radio').valid(); 152 } 153 }); 154 155 jQuery.each(jQuery('.datepicker'), function(index, datepicker) { 156 var datepicker_options = {dateFormat: 'dd/mm/yy', showOn: 'focus'}; 157 158 if (jQuery(datepicker).parent().find('.validation').val() == 'future_date_current') { 159 datepicker_options['minDate'] = new Date(); 160 } 161 162 jQuery(datepicker).datepicker(datepicker_options); 163 }); 164 165 jQuery.each(jQuery('.new_datepicker'), function(index, datepicker) { 166 var datepicker_options = {dateFormat: 'mm/dd/yy', showOn: 'focus'}; 167 168 if (jQuery(datepicker).parent().find('.validation').val() == 'future_date_current') { 169 datepicker_options['minDate'] = new Date(); 170 } 171 172 jQuery(datepicker).datepicker(datepicker_options); 173 }); 174 175});
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.