1$(function () { 2 // Disable animation in forms to improve the scroll functionality 3 jQuery.fx.off = true; 4 // Added custom validation rule to check if char limit on text area is exceeded 5 jQuery.validator.addMethod("charLimitExceeded", function (value, element) { 6 var valueLength = value.length; 7 var maxLength = element.getAttribute("data-maxlength"); 8 return valueLength <= maxLength; 9 }, ""); 10 $('textarea.textarea-input').each(function () { 11 $(this).rules("add", 12 { 13 charLimitExceeded: true 14 }); 15 }); 16 17 // Add correct error state styles on textareas 18 // aria-describedby attribute is added when textarea is invalid 19 $("textarea.textarea-input").on("input blur", function () { 20 var maxLength = parseInt($(this).attr("data-maxlength")); 21 if ($(this).attr('aria-describedby')) { 22 if ($(this).val().length && $(this).val().length <= maxLength) { 23 $(this).closest(".textarea-container").removeClass("input-error"); 24 } else { 25 $(this).closest(".textarea-container").addClass("input-error"); 26 } 27 } 28 }); 29 30 // Enahance sitecore forms that have instruction text published 31 // Associate the instruction text with the input element using aria-describedby 32 // Move the instruction text to be after the label element 33 const inputEls = document.querySelectorAll('.sc-form input:not([type=hidden]') 34 35 inputEls.forEach((inputEl) => { 36 // Find the sibling element with the class 'form-text-label' within the same parent 37 const textLabelEl = inputEl?.parentElement?.querySelector(':scope > .form-text-label') 38 39 if (textLabelEl != null) { 40 // Get the ID of the text label element 41 const textLabelElId = textLabelEl?.getAttribute('id') 42 43 if (textLabelElId != null) { 44 // Set the 'aria-describedby' attribute of the input element to the ID of the text label element 45 inputEl.setAttribute('aria-describedby', textLabelElId) 46 } 47 48 // Get the ID of the input element 49 const inputElId = inputEl?.getAttribute('id') 50 51 if (inputElId != null) { 52 // Find the label element associated with the input element using the 'for' attribute 53 const labelEl = inputEl?.parentElement?.querySelector(`label[for="${inputElId}"]`) 54 55 if (labelEl != null) { 56 // Move the text label element to be after the associated label element 57 labelEl.after(textLabelEl) 58 } 59 } 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.