MattBrown Posted July 11 Share Posted July 11 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 Link to comment
MattBrown Posted July 11 Author Share Posted July 11 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. Link to comment
paul2009 Posted July 11 Share Posted July 11 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). About: SQSP User for 17 yrs. Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF Digital, building Squarespace Extensions to supercharge your commerce website. Content: Links in my posts may refer to SF Digital products or may be affiliate links. If my advice helped, you can thank me by clicking one of the feedback emojis below. I love coffee too. Link to comment
Solution MattBrown Posted July 11 Author Solution Share Posted July 11 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. 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