Jump to content

Custom HTML code block with contact form no longer works.

Recommended Posts

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 by LeoEchero
Added website contact form link
Link to comment
  • Replies 1
  • Views 885
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.