1/** 2 * Comment URL Validation 3 * 4 * Adds front-end validation for comment form URL field. 5 * Validates URL format before submission to prevent sending invalid URLs to server. 6 */ 7 8(function() { 9 // Wait for DOM to be ready 10 document.addEventListener('DOMContentLoaded', function() { 11 // Find the comment form 12 var commentForm = document.getElementById('commentform'); 13 if (!commentForm) { 14 return; 15 } 16 17 // Find the URL input field 18 var urlInput = document.getElementById('url'); 19 if (!urlInput) { 20 return; 21 } 22 23 urlInput.addEventListener('blur', function() { 24 var urlValue = this.value.trim(); 25 26 if (urlValue === '') { 27 this.setCustomValidity(''); 28 return; 29 } 30 31 // Require protocol 32 if (!/^https?:\/\//i.test(urlValue)) { 33 this.setCustomValidity('Please enter a valid website URL (e.g. https://example.com)'); 34 return; 35 } 36 37 var domain = urlValue.replace(/^https?:\/\//i, '').split('/')[0].split('?')[0].split('#')[0]; 38 39 var domainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]?(\.[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]?)*\.[a-zA-Z]{2,}$/; 40 41 if (!domainRegex.test(domain)) { 42 this.setCustomValidity('Please enter a valid website URL (e.g. https://example.com)'); 43 } else { 44 this.setCustomValidity(''); 45 } 46 }); 47 }); 48})();
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.