1/** 2 * Zoho CRM Form Validation Script 3 * For WebToLeads form ID: 1038252000135548015 4 * Guardian Energy Management Solutions 5 */ 6 7function addAriaSelected1038252000135548015() { 8 var optionElem = event.target; 9 var previousSelectedOption = optionElem.querySelector('[aria-selected=true]'); 10 if (previousSelectedOption) { 11 previousSelectedOption.removeAttribute('aria-selected'); 12 } 13 optionElem.querySelectorAll('option')[optionElem.selectedIndex].ariaSelected = 'true'; 14} 15 16function validateEmail1038252000135548015() { 17 var form = document.forms['WebToLeads1038252000135548015']; 18 var emailFld = form.querySelectorAll('[ftype=email]'); 19 var i; 20 for (i = 0; i < emailFld.length; i++) { 21 var emailVal = emailFld[i].value; 22 if ((emailVal.replace(/^\s+|\s+$/g, '')).length != 0) { 23 var atpos = emailVal.indexOf('@'); 24 var dotpos = emailVal.lastIndexOf('.'); 25 if (atpos < 1 || dotpos < atpos + 2 || dotpos + 2 >= emailVal.length) { 26 alert('Please enter a valid email address.'); 27 emailFld[i].focus(); 28 return false; 29 } 30 } 31 } 32 return true; 33} 34 35function checkMandatory1038252000135548015() { 36 var mndFileds = new Array('Company', 'First Name', 'Last Name', 'Email', 'Phone', 'Description'); 37 var fldLangVal = new Array('Company', 'First Name', 'Last Name', 'Email', 'Phone', 'Description'); 38 var i; 39 for (i = 0; i < mndFileds.length; i++) { 40 var fieldObj = document.forms['WebToLeads1038252000135548015'][mndFileds[i]]; 41 if (fieldObj) { 42 if (((fieldObj.value).replace(/^\s+|\s+$/g, '')).length == 0) { 43 if (fieldObj.type == 'file') { 44 alert('Please select a file to upload.'); 45 fieldObj.focus(); 46 return false; 47 } 48 alert(fldLangVal[i] + ' cannot be empty.'); 49 fieldObj.focus(); 50 return false; 51 } 52 else if (fieldObj.nodeName == 'SELECT') { 53 if (fieldObj.options[fieldObj.selectedIndex].value == '-None-') { 54 alert(fldLangVal[i] + ' cannot be none.'); 55 fieldObj.focus(); 56 return false; 57 } 58 } 59 else if (fieldObj.type == 'checkbox') { 60 if (fieldObj.checked == false) { 61 alert('Please accept ' + fldLangVal[i]); 62 fieldObj.focus(); 63 return false; 64 } 65 } 66 try { 67 if (fieldObj.name == 'Last Name') { 68 name = fieldObj.value; 69 } 70 } 71 catch (e) {} 72 } 73 } 74 75 trackVisitor1038252000135548015(); 76 77 if (!validateEmail1038252000135548015()) { 78 return false; 79 } 80 81 var urlparams = new URLSearchParams(window.location.search); 82 if (urlparams.has('service') && (urlparams.get('service') === 'smarturl')) { 83 var webform = document.getElementById('webform1038252000135548015'); 84 var service = urlparams.get('service'); 85 var smarturlfield = document.createElement('input'); 86 smarturlfield.setAttribute('type', 'hidden'); 87 smarturlfield.setAttribute('value', service); 88 smarturlfield.setAttribute('name', 'service'); 89 webform.appendChild(smarturlfield); 90 } 91 92 document.querySelector('.crmWebToEntityForm .formsubmit').setAttribute('disabled', true); 93 return true; 94} 95 96function tooltipShow1038252000135548015(el) { 97 var tooltip = el.nextElementSibling; 98 var tooltipDisplay = tooltip.style.display; 99 if (tooltipDisplay == 'none') { 100 var allTooltip = document.getElementsByClassName('zcwf_tooltip_over'); 101 var i; 102 for (i = 0; i < allTooltip.length; i++) { 103 allTooltip[i].style.display = 'none'; 104 } 105 tooltip.style.display = 'block'; 106 } 107 else { 108 tooltip.style.display = 'none'; 109 } 110} 111 112// Zoho Visitor Tracking 113function trackVisitor1038252000135548015() { 114 var name = ''; 115 var email = ''; 116 try { 117 // Check if $zoho and its nested properties exist 118 if (typeof $zoho !== 'undefined' && 119 $zoho && 120 $zoho.salesiq && 121 $zoho.salesiq.visitor && 122 typeof $zoho.salesiq.visitor.uniqueid === 'function') { 123 124 var LDTuvidObj = document.forms['WebToLeads1038252000135548015']['LDTuvid']; 125 if (LDTuvidObj) { 126 LDTuvidObj.value = $zoho.salesiq.visitor.uniqueid(); 127 } 128 var firstnameObj = document.forms['WebToLeads1038252000135548015']['First Name']; 129 if (firstnameObj) { 130 name = firstnameObj.value + ' ' + name; 131 } 132 if (typeof $zoho.salesiq.visitor.name === 'function') { 133 $zoho.salesiq.visitor.name(name); 134 } 135 var emailObj = document.forms['WebToLeads1038252000135548015']['Email']; 136 if (emailObj) { 137 email = emailObj.value; 138 if (typeof $zoho.salesiq.visitor.email === 'function') { 139 $zoho.salesiq.visitor.email(email); 140 } 141 } 142 } 143 } 144 catch (e) { 145 console.log('Zoho visitor tracking error (non-critical):', e.message); 146 } 147} 148 149// Initialize Zoho SalesIQ with better error handling 150function initializeZohoSalesIQ() { 151 // Only initialize if not already loaded and not a local development environment 152 if (typeof $zoho === 'undefined' && window.location.protocol !== 'file:' && window.location.hostname !== 'guardian-energycom.local') { 153 window.$zoho = window.$zoho || {}; 154 window.$zoho.salesiq = window.$zoho.salesiq || { 155 widgetcode: 'siq88be666c6e33ce079fd84926ecd361a49469a1e1f17e69798c0b1a712c3bf33bb3c40cc7516d08f9c3d30c1a28945496', 156 values: {}, 157 ready: function() {}, 158 visitor: { 159 uniqueid: function() { return ''; }, 160 name: function(name) { return; }, 161 email: function(email) { return; } 162 } 163 }; 164 165 try { 166 var d = document; 167 var s = d.createElement('script'); 168 s.type = 'text/javascript'; 169 s.id = 'zsiqscript'; 170 s.defer = true; 171 s.src = 'https://salesiq.zoho.com/widget'; 172 s.onerror = function() { 173 console.log('Zoho SalesIQ widget failed to load - this is normal for local development'); 174 }; 175 var t = d.getElementsByTagName('script')[0]; 176 if (t && t.parentNode) { 177 t.parentNode.insertBefore(s, t); 178 } 179 } catch (e) { 180 console.log('Zoho SalesIQ initialization error:', e.message); 181 } 182 } 183} 184 185// Initialize SalesIQ 186initializeZohoSalesIQ(); 187 188// Attach validation to form when DOM is ready 189document.addEventListener('DOMContentLoaded', function() { 190 var form = document.getElementById('webform1038252000135548015'); 191 if (form) { 192 // Store our validation function 193 var originalValidation = function(event) { 194 // Use modern charset setting instead of deprecated document.charset 195 if (document.characterSet) { 196 // Modern way - read-only property 197 document.documentElement.setAttribute('charset', 'UTF-8'); 198 } 199 200 var isValid = checkMandatory1038252000135548015(); 201 if (!isValid && event) { 202 event.preventDefault(); 203 event.stopPropagation(); 204 return false;
205 } 206 return isValid; 207 }; 208 209 // Set up form validation with priority over other scripts 210 form.onsubmit = originalValidation; 211 form.setAttribute('onsubmit', 'return checkMandatory1038252000135548015()'); 212 213 // Add event listener to ensure our validation runs first 214 form.addEventListener('submit', function(event) { 215 var isValid = checkMandatory1038252000135548015(); 216 if (!isValid) { 217 event.preventDefault(); 218 event.stopPropagation(); 219 return false; 220 } 221 return true; 222 }, true); // Use capture phase to run before other handlers 223 224 // Periodically check and restore our validation if it gets overridden 225 var intervalId = setInterval(function() { 226 if (form.onsubmit !== originalValidation) { 227 console.log('Form validation was overridden, restoring...'); 228 form.onsubmit = originalValidation; 229 } 230 }, 1000); 231 232 // Stop monitoring after 10 seconds (other scripts should be loaded by then) 233 setTimeout(function() { 234 clearInterval(intervalId); 235 }, 10000); 236 237 console.log('Zoho form validation attached successfully with override protection'); 238 239 // Load analytics script asynchronously to avoid parser-blocking 240 loadZohoAnalyticsAsync(); 241 } else { 242 console.log('Zoho form not found - validation not attached'); 243 } 244}); 245 246// Load Zoho analytics script asynchronously to avoid document.write warnings 247function loadZohoAnalyticsAsync() { 248 // Only load if not already loaded and we're on the production site 249 if (!document.getElementById('zoho-analytics-loaded') && 250 window.location.hostname !== 'guardian-energycom.local') { 251 252 var script = document.createElement('script'); 253 script.id = 'zoho-analytics-loaded'; 254 script.async = true; 255 script.defer = true; 256 257 // Zoho WebFormAnalyticsServlet URL (replace with your actual analytics URL) 258 script.src = 'https://crm.zohopublic.com/crm/WebFormAnalyticsServeServlet?rid=6cd0697ea38ea8ca2be82e92b8ddfa78a18cf588c787a378a14921bc908baf36e11b8b7109b229cb45c53ec9465c336agid05c346fc49eabf03f14469f294c8f81b8ddd020ca118756fb71176c9e54122c4giddc8a6a8a47eb385ecd1ce733d261182561aa0f5af910367d3c31a4e4a8ea4033gidc8f3e63b8c6dd1dbb3480e10f9d55016974d8489f4ec6748fd5d50424695bba9&tw=f58852178fed14339c565da3a156a351af06174739fa55d1e90f980da01737fc'; 259 260 script.onerror = function() { 261 console.log('Zoho analytics script failed to load (non-critical)'); 262 }; 263 264 // Append to head instead of using document.write 265 var head = document.head || document.getElementsByTagName('head')[0]; 266 if (head) { 267 head.appendChild(script); 268 } 269 } 270}
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.