1(function () { 2 'use strict'; 3 4 var zipPattern = /^[0-9]{5}$/; 5 var forms = document.querySelectorAll('.gli-quote-capture__form'); 6 7 Array.prototype.forEach.call(forms, function (form) { 8 var input = form.querySelector('.gli-quote-capture__input'); 9 var error = form.querySelector('.gli-quote-capture__error'); 10 11 if (!input || !error) { 12 return; 13 } 14 15 var message = error.textContent.trim(); 16 17 function clearError() { 18 input.setCustomValidity(''); 19 input.setAttribute('aria-invalid', 'false'); 20 error.hidden = true; 21 } 22 23 function showError() { 24 input.setCustomValidity(message); 25 input.setAttribute('aria-invalid', 'true'); 26 error.hidden = false; 27 } 28 29 /* The HTML constraints remain active whenever this enhancement is absent. */ 30 form.noValidate = true; 31 32 input.addEventListener('input', function () { 33 input.setCustomValidity(''); 34 35 if (zipPattern.test(input.value.trim())) { 36 clearError(); 37 } else if (input.getAttribute('aria-invalid') === 'true') { 38 showError(); 39 } 40 }); 41 42 form.addEventListener('submit', function (event) { 43 var value = input.value.trim(); 44 input.value = value; 45 46 if (!zipPattern.test(value)) { 47 event.preventDefault(); 48 showError(); 49 50 if (typeof input.reportValidity === 'function') { 51 input.reportValidity(); 52 } else { 53 input.focus(); 54 } 55 56 return; 57 } 58 59 clearError(); 60 }); 61 }); 62}());
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.