MattBrown Posted July 11, 2023 Posted July 11, 2023 Hey There, I have run into an issue with Squarespace's javascript related to forms. On our site, I have custom code to pre-fill user information into some forms. Here is a basic example: $(document).ready(function() { var myForms = document.getElementsByClassName('form-wrapper'); for (var i=0; i < myForms.length; i++) { formFiller(myForms[i]); } }); function formFiller(thisForm) { //console.log(thisForm); var myInputs = thisForm.getElementsByTagName('Input'); for (var j=0; j < myInputs.length; j++) { if (myInputs[j].name === 'fname') myInputs[j].value = "Matt"; if (myInputs[j].name === 'lname') myInputs[j].value = "Brown"; if (myInputs[j].type === 'email') myInputs[j].value = "admin@"; } } Unfortunately, starting sometime this last spring, Squarespace's javascript code related to forms will delete any pre-filled data as soon as a user enters any characters into any of the form items in the same form. You can see an example of this here:https://www.crescentproject.org/test3 I have tried listening for changes to the form items and re-filling them but they are deleted again by Squarespace's javascript and looks really odd from a user point of view. Squarespace support was able to reproduce the issue (which was appreciated) but then asserts that it is a user code issue, so not their problem. Does anyone have suggestions for a work-around or how to address this with Squarespace so they will fix their bug? Thanks Matt
MattBrown Posted July 11, 2023 Author Posted July 11, 2023 Update - the issue is getting forwarded on to engineering to have a look at. Still - it would be great to have a work-around if there are any suggestions.
paul2009 Posted July 11, 2023 Posted July 11, 2023 1 hour ago, MattBrown said: starting sometime this last spring, Squarespace's javascript code related to forms will delete any pre-filled data. Does anyone have suggestions for a work-around or how to address this with Squarespace so they will fix their bug? This isn’t a bug. In May, Squarespace replaced the form block with a new React based form and this means you cannot set the value in this way. React won’t be aware of the change (it is only a change to the DOM). Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.
Solution MattBrown Posted July 11, 2023 Author Solution Posted July 11, 2023 Also - found your response on another post which lead to this which seems to be a way to implement this with the new React forms.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment