1(function () { 2 // selector limited to CF7 forms; change to 'input[type="tel"]' to apply site-wide 3 const TEL_SELECTOR = 'form.wpcf7-form input[type="tel"]'; 4 5 function onlyDigits(str) { return str.replace(/\D+/g, ''); } 6 7 function setup(el) { 8 // better mobile keypad + hints (doesn't rely on CF7) 9 el.setAttribute('inputmode', 'numeric'); 10 el.setAttribute('autocomplete', 'tel'); 11 el.setAttribute('pattern', '\\d*'); 12 } 13 14 function sanitize(el) { 15 const before = el.value; 16 const caret = el.selectionStart || 0; 17 18 let v = onlyDigits(before); 19 // Respect maxlength if you've set it in CF7 (e.g., maxlength:10) 20 const max = el.maxLength > 0 ? el.maxLength : null; 21 if (max) v = v.slice(0, max); 22 23 // adjust caret after stripping non-digits 24 const nonDigitsBefore = (before.slice(0, caret).match(/\D/g) || []).length; 25 el.value = v; 26 const newPos = Math.max(0, Math.min(v.length, caret - nonDigitsBefore)); 27 try { el.setSelectionRange(newPos, newPos); } catch (e) {} 28 } 29 30 // Delegate so it also works for forms loaded later 31 document.addEventListener('focusin', function (e) { 32 if (e.target.matches(TEL_SELECTOR)) setup(e.target); 33 }); 34 35 document.addEventListener('input', function (e) { 36 if (e.target.matches(TEL_SELECTOR)) sanitize(e.target); 37 }, true); 38 39 document.addEventListener('paste', function (e) { 40 if (!e.target.matches(TEL_SELECTOR)) return; 41 e.preventDefault(); 42 const clip = (e.clipboardData || window.clipboardData).getData('text') || ''; 43 let insert = onlyDigits(clip); 44 const max = e.target.maxLength > 0 ? e.target.maxLength : null; 45 if (max) insert = insert.slice(0, max); 46 e.target.value = insert; 47 try { e.target.setSelectionRange(insert.length, insert.length); } catch (err) {} 48 }); 49 50 // Initialize existing fields on load 51 document.addEventListener('DOMContentLoaded', function () { 52 document.querySelectorAll(TEL_SELECTOR).forEach(setup); 53 }); 54})(); 55 56document.addEventListener('DOMContentLoaded', function() { 57 const linkFTTH = document.getElementById('custom-tab-wrapper-link-ftth'); 58 const linkFTTB = document.getElementById('custom-tab-wrapper-link-fttb'); 59 60 if (linkFTTH) { 61 linkFTTH.addEventListener('click', function(e) { 62 e.preventDefault(); 63 window.location.href = 'https://portal.zoomonline.com/login'; // replace with your actual link 64 }); 65 } 66 67 if (linkFTTB) { 68 linkFTTB.addEventListener('click', function(e) { 69 e.preventDefault(); 70 window.location.href = 'https://zoomonline.com/business-form/'; // replace with your actual link 71 }); 72 } 73});
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.