LeoEchero Posted August 7, 2023 Share Posted August 7, 2023 (edited) I used to have simple HTML code block to add the character count and to limit a number of characters allowed in the text area of the contact form. However, it looks like sometime this summer Squarespace updated the variables for the contact forms which broke the code. Is there a list of new variables anywhere? I think messageField is the problem but it could be anything else at this point. Please help. Here's what it looked like:<script> document.addEventListener("DOMContentLoaded", function() { var messageField = document.querySelector("#message"); var maxLength = 200; messageField.setAttribute("maxlength", maxLength); var counter = document.createElement("div"); counter.classList.add("char-counter"); counter.innerHTML = "<span>" + maxLength + "</span> characters left"; messageField.parentNode.insertBefore(counter, messageField.nextSibling); messageField.addEventListener("input", function() { var currentLength = messageField.value.length; var remaining = maxLength - currentLength; counter.querySelector("span").innerHTML = remaining; if (remaining < 0) { messageField.classList.add("is-error"); } else { messageField.classList.remove("is-error"); } }); }); </script> Edited August 7, 2023 by LeoEchero Added website contact form link Link to comment
tuanphan Posted August 9, 2023 Share Posted August 9, 2023 You can disable this form update by reading this Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment